Skip to content

Commit

Permalink
Merge pull request #8578 from magento-l3/PR-VK-2023-09-29
Browse files Browse the repository at this point in the history
PR-L3-VK-2023-09-29
  • Loading branch information
2 parents 2f5faa7 + fec5184 commit 1819863
Show file tree
Hide file tree
Showing 56 changed files with 1,521 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Magento\Catalog\Model\Entity\Attribute;
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
use Magento\Framework\Data\FormFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Registry;

/**
Expand Down Expand Up @@ -58,6 +59,7 @@ public function __construct(
* @inheritDoc
* @return $this
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @throws LocalizedException
*/
protected function _prepareForm()
{
Expand Down Expand Up @@ -176,28 +178,34 @@ protected function _prepareForm()
['form' => $form, 'attribute' => $attributeObject]
);

$dependencies = $this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Form\Element\Dependence::class
)->addFieldMap(
"is_html_allowed_on_front",
'html_allowed_on_front'
)->addFieldMap(
"frontend_input",
'frontend_input_type'
)->addFieldMap(
"is_searchable",
'searchable'
)->addFieldMap(
"is_visible_in_advanced_search",
'advanced_search'
)->addFieldDependence(
'advanced_search',
'searchable',
'1'
);
$this->_eventManager->dispatch(
'adminhtml_catalog_product_attribute_edit_frontend_prepare_field_dependencies',
['dependencies' => $dependencies]
);

// define field dependencies
$this->setChild(
'form_after',
$this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Form\Element\Dependence::class
)->addFieldMap(
"is_html_allowed_on_front",
'html_allowed_on_front'
)->addFieldMap(
"frontend_input",
'frontend_input_type'
)->addFieldMap(
"is_searchable",
'searchable'
)->addFieldMap(
"is_visible_in_advanced_search",
'advanced_search'
)->addFieldDependence(
'advanced_search',
'searchable',
'1'
)
$dependencies
);

$this->setForm($form);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<actionGroup ref="AdminSetProductAttributeUseInLayeredNavigationOptionActionGroup" stepKey="setDropdownUseInLayeredNavigationNoResults">
<argument name="useInLayeredNavigationValue" value="Filterable (with results)"/>
</actionGroup>
<selectOption selector="{{AdvancedAttributePropertiesSection.UseInSearch}}" userInput="Yes" stepKey="selectIsSearchAble"/>
<selectOption selector="{{AttributePropertiesSection.useInSearchResultsLayeredNavigation}}" userInput="Yes" stepKey="selectUseInLayeredNavigationOption"/>
<click stepKey="saveAttribute" selector="{{AttributePropertiesSection.Save}}"/>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="QuickSearchProductByAttributeNotSearchableUsedInLayeredNavigationTest">
<annotations>
<stories value="Search Product on Storefront"/>
<title value="Products should not appear in search results when search by attribute value if attribute has the Use in search set to No"/>
<description value="A product should not be searchable by attribute value if attribute has 'Use in search' to 'No' even if 'Use in Layered Navigation is set"/>
<severity value="MAJOR"/>
<testCaseId value="AC-9146"/>
<group value="CatalogSearch"/>
</annotations>
<before>
<!--Create category, attribute set with multiselect product attribute with two options-->
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
<createData entity="CatalogAttributeSet" stepKey="createAttributeSet"/>
<createData entity="multipleSelectProductAttribute" stepKey="createMultiselectAttribute"/>
<createData entity="ProductAttributeOption10" stepKey="firstMultiselectOption">
<requiredEntity createDataKey="createMultiselectAttribute"/>
</createData>
<createData entity="ProductAttributeOption11" stepKey="secondMultiselectOption">
<requiredEntity createDataKey="createMultiselectAttribute"/>
</createData>
<getData entity="ProductAttributeOptionGetter" index="1" stepKey="getFirstMultiselectOption">
<requiredEntity createDataKey="createMultiselectAttribute"/>
</getData>
<getData entity="ProductAttributeOptionGetter" index="2" stepKey="getSecondMultiselectOption">
<requiredEntity createDataKey="createMultiselectAttribute"/>
</getData>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/$createAttributeSet.attribute_set_id$/" stepKey="onAttributeSetEdit"/>
<waitForPageLoad stepKey="waitForAttributeSetPageLoad"/>
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignMultiselectAttributeToGroup">
<argument name="group" value="Product Details"/>
<argument name="attribute" value="$createMultiselectAttribute.attribute_code$"/>
</actionGroup>
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="saveAttributeSet"/>

<!-- Create simple product with multiselect attribute -->
<createData entity="SimpleOne" storeCode="all" stepKey="createFirstSimpleProduct">
<field key="attribute_set_id">$createAttributeSet.attribute_set_id$</field>
<requiredEntity createDataKey="createMultiselectAttribute"/>
<requiredEntity createDataKey="getFirstMultiselectOption"/>
<requiredEntity createDataKey="createCategory"/>
</createData>
</before>
<after>
<deleteData createDataKey="createFirstSimpleProduct" stepKey="deleteFirstSimpleProduct"/>
<deleteData createDataKey="createMultiselectAttribute" stepKey="deleteMultiselectAttribute"/>
<deleteData createDataKey="createAttributeSet" stepKey="deleteAttributeSet"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<!-- Set Use in layered navigation for attribute to Filterable -->
<actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="goToDropdownAttributePage">
<argument name="productAttributeCode" value="$createMultiselectAttribute.attribute_code$"/>
</actionGroup>
<actionGroup ref="AdminSetUseInSearchValueForProductAttributeActionGroup" stepKey="makeAttributeUnsearchableInAQuickSearch">
<argument name="useInSearchValue" value="No"/>
</actionGroup>
<actionGroup ref="AdminSetProductAttributeUseInLayeredNavigationOptionActionGroup" stepKey="setDropdownUseInLayeredNavigationNoResults">
<argument name="useInLayeredNavigationValue" value="Filterable (no results)"/>
</actionGroup>
<actionGroup ref="AdminProductAttributeSaveActionGroup" stepKey="saveMultiSelectAttribute"/>

<!-- Perform search with attribute value -->
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToFrontPage"/>
<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="searchStorefront">
<argument name="phrase" value="$getFirstMultiselectOption.label$"/>
</actionGroup>

<!-- Should not see any search results -->
<dontSee userInput="$$createFirstSimpleProduct.sku$$" selector="{{StorefrontCatalogSearchMainSection.searchResults}}" stepKey="dontSeeProduct"/>
<see selector="{{StorefrontCatalogSearchMainSection.message}}" userInput="Your search returned no results." stepKey="seeCantFindProductOneMessage"/>
</test>
</tests>
3 changes: 0 additions & 3 deletions app/code/Magento/CatalogSearch/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
<type name="Magento\Catalog\Model\Product\Action">
<plugin name="catalogsearchFulltextMassAction" type="Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Product\Action"/>
</type>
<type name="Magento\Catalog\Model\Indexer\Product\Category\Action\Rows">
<plugin name="catalogsearchFulltextCategoryAssignment" type="Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Product\Category\Action\Rows"/>
</type>
<type name="Magento\Store\Model\ResourceModel\Store">
<plugin name="catalogsearchFulltextIndexerStoreView" type="Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Store\View" />
</type>
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/CatalogSearch/etc/search_request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
<queryReference clause="must" ref="visibility"/>
</query>
<query xsi:type="matchQuery" value="$search_term$" name="search">
<match field="*"/>
<match field="name" matchCondition="match_phrase_prefix"/>
</query>
<query xsi:type="matchQuery" value="$search_term$" name="partial_search">
<match field="*"/>
<match field="name" matchCondition="match_phrase_prefix"/>
<match field="sku" matchCondition="match_phrase_prefix"/>
</query>
Expand Down
13 changes: 13 additions & 0 deletions app/code/Magento/Customer/Model/Plugin/CustomerNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public function beforeExecute(ActionInterface $subject)

if (!$this->isFrontendRequest()
|| !$this->isPostRequest()
|| $this->isLogoutRequest()
|| !$this->isSessionUpdateRegisteredFor($customerId)) {
return;
}
Expand Down Expand Up @@ -146,6 +147,18 @@ private function isPostRequest(): bool
return $this->request instanceof HttpRequestInterface && $this->request->isPost();
}

/**
* Checks if the current request is a logout request.
*
* @return bool
*/
private function isLogoutRequest(): bool
{
return $this->request->getRouteName() === 'customer'
&& $this->request->getControllerName() === 'account'
&& $this->request->getActionName() === 'logout';
}

/**
* Check if the current application area is frontend.
*
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
<item>6161 West Centinela Avenue</item>
</array>
<data key="city">Culver City</data>
<data key="country_id">United States</data>
<data key="country_id">US</data>
<data key="country">United States</data>
<data key="state">California</data>
<data key="postcode">90230</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Magento\Framework\Session\StorageInterface;
use Magento\Framework\App\Request\Http as RequestHttp;

/**
* Unit test for CustomerNotification plugin
Expand Down Expand Up @@ -83,8 +84,7 @@ protected function setUp(): void

$this->customerRepositoryMock = $this->getMockForAbstractClass(CustomerRepositoryInterface::class);
$this->actionMock = $this->getMockForAbstractClass(ActionInterface::class);
$this->requestMock = $this->getMockBuilder(RequestStubInterface::class)
->getMockForAbstractClass();
$this->requestMock = $this->createMock(RequestHttp::class);
$this->requestMock->method('isPost')->willReturn(true);

$this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
Expand Down Expand Up @@ -153,4 +153,17 @@ public function testBeforeDispatchWithNoCustomerFound()

$this->plugin->beforeExecute($this->actionMock);
}

public function testBeforeExecuteForLogoutRequest()
{
$this->requestMock->method('getRouteName')->willReturn('customer');
$this->requestMock->method('getControllerName')->willReturn('account');
$this->requestMock->method('getActionName')->willReturn('logout');

$this->sessionMock->expects($this->never())->method('regenerateId');
$this->sessionMock->expects($this->never())->method('setCustomerData');
$this->sessionMock->expects($this->never())->method('setCustomerGroupId');

$this->plugin->beforeExecute($this->actionMock);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ public function getField(AbstractAttribute $attribute): array
),
'index' => $this->indexTypeConverter->convert(
IndexTypeConverterInterface::INTERNAL_NO_ANALYZE_VALUE
)
),
'normalizer' => 'folding',
];
}

Expand Down Expand Up @@ -202,7 +203,8 @@ public function getField(AbstractAttribute $attribute): array
),
'index' => $this->indexTypeConverter->convert(
IndexTypeConverterInterface::INTERNAL_NO_ANALYZE_VALUE
)
),
'normalizer' => 'folding',
];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public function build()
'tokenizer' => $tokenizer,
'filter' => array_merge($filter, $synonymFilter),
'char_filter' => $charFilter,
'normalizer' => [
'folding' => [
'type' => 'custom',
'filter' => ['asciifolding', 'lowercase'],
],
],
],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function afterExecute(

$productIds = array_merge([], ...$productIds);
if (!empty($productIds)) {
$indexer->reindexList(array_unique($productIds));
$indexer->getView()->getChangelog()->addList($productIds);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function attributeProvider(): array
'sort_attr_code' => [
'type' => 'string',
'index' => 'not_analyzed',
'normalizer' => 'folding',
],
],
],
Expand Down Expand Up @@ -375,6 +376,7 @@ public function attributeProvider(): array
'sort_attr_code' => [
'type' => 'string',
'index' => 'not_analyzed',
'normalizer' => 'folding',
],
],
],
Expand Down
Loading

0 comments on commit 1819863

Please sign in to comment.