Skip to content

Commit 1819863

Browse files
Merge pull request #8578 from magento-l3/PR-VK-2023-09-29
PR-L3-VK-2023-09-29
2 parents 2f5faa7 + fec5184 commit 1819863

File tree

56 files changed

+1521
-282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1521
-282
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Catalog\Model\Entity\Attribute;
1414
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
1515
use Magento\Framework\Data\FormFactory;
16+
use Magento\Framework\Exception\LocalizedException;
1617
use Magento\Framework\Registry;
1718

1819
/**
@@ -58,6 +59,7 @@ public function __construct(
5859
* @inheritDoc
5960
* @return $this
6061
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
62+
* @throws LocalizedException
6163
*/
6264
protected function _prepareForm()
6365
{
@@ -176,28 +178,34 @@ protected function _prepareForm()
176178
['form' => $form, 'attribute' => $attributeObject]
177179
);
178180

181+
$dependencies = $this->getLayout()->createBlock(
182+
\Magento\Backend\Block\Widget\Form\Element\Dependence::class
183+
)->addFieldMap(
184+
"is_html_allowed_on_front",
185+
'html_allowed_on_front'
186+
)->addFieldMap(
187+
"frontend_input",
188+
'frontend_input_type'
189+
)->addFieldMap(
190+
"is_searchable",
191+
'searchable'
192+
)->addFieldMap(
193+
"is_visible_in_advanced_search",
194+
'advanced_search'
195+
)->addFieldDependence(
196+
'advanced_search',
197+
'searchable',
198+
'1'
199+
);
200+
$this->_eventManager->dispatch(
201+
'adminhtml_catalog_product_attribute_edit_frontend_prepare_field_dependencies',
202+
['dependencies' => $dependencies]
203+
);
204+
179205
// define field dependencies
180206
$this->setChild(
181207
'form_after',
182-
$this->getLayout()->createBlock(
183-
\Magento\Backend\Block\Widget\Form\Element\Dependence::class
184-
)->addFieldMap(
185-
"is_html_allowed_on_front",
186-
'html_allowed_on_front'
187-
)->addFieldMap(
188-
"frontend_input",
189-
'frontend_input_type'
190-
)->addFieldMap(
191-
"is_searchable",
192-
'searchable'
193-
)->addFieldMap(
194-
"is_visible_in_advanced_search",
195-
'advanced_search'
196-
)->addFieldDependence(
197-
'advanced_search',
198-
'searchable',
199-
'1'
200-
)
208+
$dependencies
201209
);
202210

203211
$this->setForm($form);

app/code/Magento/Catalog/Test/Mftf/Test/SavingCustomAttributeValuesUsingUITest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<actionGroup ref="AdminSetProductAttributeUseInLayeredNavigationOptionActionGroup" stepKey="setDropdownUseInLayeredNavigationNoResults">
5656
<argument name="useInLayeredNavigationValue" value="Filterable (with results)"/>
5757
</actionGroup>
58+
<selectOption selector="{{AdvancedAttributePropertiesSection.UseInSearch}}" userInput="Yes" stepKey="selectIsSearchAble"/>
5859
<selectOption selector="{{AttributePropertiesSection.useInSearchResultsLayeredNavigation}}" userInput="Yes" stepKey="selectUseInLayeredNavigationOption"/>
5960
<click stepKey="saveAttribute" selector="{{AttributePropertiesSection.Save}}"/>
6061

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Category/Action/Rows.php

Lines changed: 0 additions & 52 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="QuickSearchProductByAttributeNotSearchableUsedInLayeredNavigationTest">
11+
<annotations>
12+
<stories value="Search Product on Storefront"/>
13+
<title value="Products should not appear in search results when search by attribute value if attribute has the Use in search set to No"/>
14+
<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"/>
15+
<severity value="MAJOR"/>
16+
<testCaseId value="AC-9146"/>
17+
<group value="CatalogSearch"/>
18+
</annotations>
19+
<before>
20+
<!--Create category, attribute set with multiselect product attribute with two options-->
21+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
22+
<createData entity="CatalogAttributeSet" stepKey="createAttributeSet"/>
23+
<createData entity="multipleSelectProductAttribute" stepKey="createMultiselectAttribute"/>
24+
<createData entity="ProductAttributeOption10" stepKey="firstMultiselectOption">
25+
<requiredEntity createDataKey="createMultiselectAttribute"/>
26+
</createData>
27+
<createData entity="ProductAttributeOption11" stepKey="secondMultiselectOption">
28+
<requiredEntity createDataKey="createMultiselectAttribute"/>
29+
</createData>
30+
<getData entity="ProductAttributeOptionGetter" index="1" stepKey="getFirstMultiselectOption">
31+
<requiredEntity createDataKey="createMultiselectAttribute"/>
32+
</getData>
33+
<getData entity="ProductAttributeOptionGetter" index="2" stepKey="getSecondMultiselectOption">
34+
<requiredEntity createDataKey="createMultiselectAttribute"/>
35+
</getData>
36+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
37+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/$createAttributeSet.attribute_set_id$/" stepKey="onAttributeSetEdit"/>
38+
<waitForPageLoad stepKey="waitForAttributeSetPageLoad"/>
39+
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignMultiselectAttributeToGroup">
40+
<argument name="group" value="Product Details"/>
41+
<argument name="attribute" value="$createMultiselectAttribute.attribute_code$"/>
42+
</actionGroup>
43+
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="saveAttributeSet"/>
44+
45+
<!-- Create simple product with multiselect attribute -->
46+
<createData entity="SimpleOne" storeCode="all" stepKey="createFirstSimpleProduct">
47+
<field key="attribute_set_id">$createAttributeSet.attribute_set_id$</field>
48+
<requiredEntity createDataKey="createMultiselectAttribute"/>
49+
<requiredEntity createDataKey="getFirstMultiselectOption"/>
50+
<requiredEntity createDataKey="createCategory"/>
51+
</createData>
52+
</before>
53+
<after>
54+
<deleteData createDataKey="createFirstSimpleProduct" stepKey="deleteFirstSimpleProduct"/>
55+
<deleteData createDataKey="createMultiselectAttribute" stepKey="deleteMultiselectAttribute"/>
56+
<deleteData createDataKey="createAttributeSet" stepKey="deleteAttributeSet"/>
57+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
58+
<magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
59+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
60+
</after>
61+
62+
<!-- Set Use in layered navigation for attribute to Filterable -->
63+
<actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="goToDropdownAttributePage">
64+
<argument name="productAttributeCode" value="$createMultiselectAttribute.attribute_code$"/>
65+
</actionGroup>
66+
<actionGroup ref="AdminSetUseInSearchValueForProductAttributeActionGroup" stepKey="makeAttributeUnsearchableInAQuickSearch">
67+
<argument name="useInSearchValue" value="No"/>
68+
</actionGroup>
69+
<actionGroup ref="AdminSetProductAttributeUseInLayeredNavigationOptionActionGroup" stepKey="setDropdownUseInLayeredNavigationNoResults">
70+
<argument name="useInLayeredNavigationValue" value="Filterable (no results)"/>
71+
</actionGroup>
72+
<actionGroup ref="AdminProductAttributeSaveActionGroup" stepKey="saveMultiSelectAttribute"/>
73+
74+
<!-- Perform search with attribute value -->
75+
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToFrontPage"/>
76+
<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="searchStorefront">
77+
<argument name="phrase" value="$getFirstMultiselectOption.label$"/>
78+
</actionGroup>
79+
80+
<!-- Should not see any search results -->
81+
<dontSee userInput="$$createFirstSimpleProduct.sku$$" selector="{{StorefrontCatalogSearchMainSection.searchResults}}" stepKey="dontSeeProduct"/>
82+
<see selector="{{StorefrontCatalogSearchMainSection.message}}" userInput="Your search returned no results." stepKey="seeCantFindProductOneMessage"/>
83+
</test>
84+
</tests>

app/code/Magento/CatalogSearch/etc/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
<type name="Magento\Catalog\Model\Product\Action">
3939
<plugin name="catalogsearchFulltextMassAction" type="Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Product\Action"/>
4040
</type>
41-
<type name="Magento\Catalog\Model\Indexer\Product\Category\Action\Rows">
42-
<plugin name="catalogsearchFulltextCategoryAssignment" type="Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Product\Category\Action\Rows"/>
43-
</type>
4441
<type name="Magento\Store\Model\ResourceModel\Store">
4542
<plugin name="catalogsearchFulltextIndexerStoreView" type="Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Store\View" />
4643
</type>

app/code/Magento/CatalogSearch/etc/search_request.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
<queryReference clause="must" ref="visibility"/>
2121
</query>
2222
<query xsi:type="matchQuery" value="$search_term$" name="search">
23-
<match field="*"/>
23+
<match field="name" matchCondition="match_phrase_prefix"/>
2424
</query>
2525
<query xsi:type="matchQuery" value="$search_term$" name="partial_search">
26-
<match field="*"/>
2726
<match field="name" matchCondition="match_phrase_prefix"/>
2827
<match field="sku" matchCondition="match_phrase_prefix"/>
2928
</query>

app/code/Magento/Customer/Model/Plugin/CustomerNotification.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public function beforeExecute(ActionInterface $subject)
110110

111111
if (!$this->isFrontendRequest()
112112
|| !$this->isPostRequest()
113+
|| $this->isLogoutRequest()
113114
|| !$this->isSessionUpdateRegisteredFor($customerId)) {
114115
return;
115116
}
@@ -146,6 +147,18 @@ private function isPostRequest(): bool
146147
return $this->request instanceof HttpRequestInterface && $this->request->isPost();
147148
}
148149

150+
/**
151+
* Checks if the current request is a logout request.
152+
*
153+
* @return bool
154+
*/
155+
private function isLogoutRequest(): bool
156+
{
157+
return $this->request->getRouteName() === 'customer'
158+
&& $this->request->getControllerName() === 'account'
159+
&& $this->request->getActionName() === 'logout';
160+
}
161+
149162
/**
150163
* Check if the current application area is frontend.
151164
*

app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@
381381
<item>6161 West Centinela Avenue</item>
382382
</array>
383383
<data key="city">Culver City</data>
384-
<data key="country_id">United States</data>
384+
<data key="country_id">US</data>
385385
<data key="country">United States</data>
386386
<data key="state">California</data>
387387
<data key="postcode">90230</data>

app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerNotificationTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use PHPUnit\Framework\TestCase;
2222
use Psr\Log\LoggerInterface;
2323
use Magento\Framework\Session\StorageInterface;
24+
use Magento\Framework\App\Request\Http as RequestHttp;
2425

2526
/**
2627
* Unit test for CustomerNotification plugin
@@ -83,8 +84,7 @@ protected function setUp(): void
8384

8485
$this->customerRepositoryMock = $this->getMockForAbstractClass(CustomerRepositoryInterface::class);
8586
$this->actionMock = $this->getMockForAbstractClass(ActionInterface::class);
86-
$this->requestMock = $this->getMockBuilder(RequestStubInterface::class)
87-
->getMockForAbstractClass();
87+
$this->requestMock = $this->createMock(RequestHttp::class);
8888
$this->requestMock->method('isPost')->willReturn(true);
8989

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

154154
$this->plugin->beforeExecute($this->actionMock);
155155
}
156+
157+
public function testBeforeExecuteForLogoutRequest()
158+
{
159+
$this->requestMock->method('getRouteName')->willReturn('customer');
160+
$this->requestMock->method('getControllerName')->willReturn('account');
161+
$this->requestMock->method('getActionName')->willReturn('logout');
162+
163+
$this->sessionMock->expects($this->never())->method('regenerateId');
164+
$this->sessionMock->expects($this->never())->method('setCustomerData');
165+
$this->sessionMock->expects($this->never())->method('setCustomerGroupId');
166+
167+
$this->plugin->beforeExecute($this->actionMock);
168+
}
156169
}

app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ public function getField(AbstractAttribute $attribute): array
164164
),
165165
'index' => $this->indexTypeConverter->convert(
166166
IndexTypeConverterInterface::INTERNAL_NO_ANALYZE_VALUE
167-
)
167+
),
168+
'normalizer' => 'folding',
168169
];
169170
}
170171

@@ -202,7 +203,8 @@ public function getField(AbstractAttribute $attribute): array
202203
),
203204
'index' => $this->indexTypeConverter->convert(
204205
IndexTypeConverterInterface::INTERNAL_NO_ANALYZE_VALUE
205-
)
206+
),
207+
'normalizer' => 'folding',
206208
];
207209
}
208210
}

app/code/Magento/Elasticsearch/Model/Adapter/Index/Builder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ public function build()
105105
'tokenizer' => $tokenizer,
106106
'filter' => array_merge($filter, $synonymFilter),
107107
'char_filter' => $charFilter,
108+
'normalizer' => [
109+
'folding' => [
110+
'type' => 'custom',
111+
'filter' => ['asciifolding', 'lowercase'],
112+
],
113+
],
108114
],
109115
];
110116

app/code/Magento/Elasticsearch/Model/Indexer/Fulltext/Plugin/Category/Product/Action/Rows.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function afterExecute(
8686

8787
$productIds = array_merge([], ...$productIds);
8888
if (!empty($productIds)) {
89-
$indexer->reindexList(array_unique($productIds));
89+
$indexer->getView()->getChangelog()->addList($productIds);
9090
}
9191
}
9292

app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/StaticFieldTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ public function attributeProvider(): array
297297
'sort_attr_code' => [
298298
'type' => 'string',
299299
'index' => 'not_analyzed',
300+
'normalizer' => 'folding',
300301
],
301302
],
302303
],
@@ -375,6 +376,7 @@ public function attributeProvider(): array
375376
'sort_attr_code' => [
376377
'type' => 'string',
377378
'index' => 'not_analyzed',
379+
'normalizer' => 'folding',
378380
],
379381
],
380382
],

0 commit comments

Comments
 (0)