Skip to content

Commit 6a1e6c6

Browse files
committed
Merge remote-tracking branch 'origin/AC-6395' into Hammer_Community_Backlog_21092022
2 parents cf375ec + 4fc6000 commit 6a1e6c6

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryMainSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@
4141
<element name="productNameByPosition" type="text" selector=".products-grid li:nth-of-type({{position}}) .product-item-name a" parameterized="true"/>
4242
<element name="sidebarAdditional" type="block" selector="#maincontent .sidebar.sidebar-additional"/>
4343
<element name="searchStore" type="input" selector="//div/input[@id='search']" />
44+
<element name="productAttributeName" type="button" selector="//div[@class='filter-options-title' and contains(text(),'{{var1}}')]" parameterized="true"/>
45+
<element name="productAttributeOptionValue" type="button" selector="//div[@id='narrow-by-list']//a[contains(text(), '{{var1}}')]" parameterized="true"/>
4446
</section>
4547
</sections>

app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ private function categoryProductByCustomSortOrder(int $categoryId): array
211211
$searchCriteria = $this->searchResult->getSearchCriteria();
212212
$sortOrders = $searchCriteria->getSortOrders() ?? [];
213213
$sortOrders = array_merge(['is_salable' => \Magento\Framework\DB\Select::SQL_DESC], $sortOrders);
214-
215214
$connection = $this->collection->getConnection();
216215
$query = clone $connection->select()
217216
->reset(\Magento\Framework\DB\Select::ORDER)
@@ -231,6 +230,14 @@ private function categoryProductByCustomSortOrder(int $categoryId): array
231230
. ' AND cat_index.store_id = ' . $storeId,
232231
['cat_index.position']
233232
);
233+
234+
$productIds = [];
235+
foreach ($this->searchResult->getItems() as $item) {
236+
$productIds[] = $item->getId();
237+
}
238+
239+
$query->where('e.entity_id IN(?)', $productIds);
240+
234241
foreach ($sortOrders as $field => $dir) {
235242
if ($field === 'name') {
236243
$entityTypeId = $this->collection->getEntity()->getTypeId();
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StoreFrontSearchWithProductAttributeOptionValue">
12+
<annotations>
13+
<stories value="Store front search product when display out of stock products to yes"/>
14+
<title value="Catalog shown entire catalog items count if show_of_stock_option enabled"/>
15+
<description value="Catalog shown entire catalog items count if show_of_stock_option enabled"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="AC-6395"/>
18+
<group value="catalog_search"/>
19+
</annotations>
20+
<before>
21+
<magentoCLI command="config:set cataloginventory/options/show_out_of_stock 1" stepKey="setOutOfStockToYes"/>
22+
<magentoCLI command="cache:clean config" stepKey="cacheClean"/>
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
24+
25+
<createData entity="_defaultCategory" stepKey="createCategory"/>
26+
<createData entity="SimpleProduct" stepKey="createProduct01">
27+
<requiredEntity createDataKey="createCategory"/>
28+
</createData>
29+
30+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
31+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
32+
<requiredEntity createDataKey="createConfigProductAttribute"/>
33+
</createData>
34+
<createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2">
35+
<requiredEntity createDataKey="createConfigProductAttribute"/>
36+
</createData>
37+
<createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet">
38+
<requiredEntity createDataKey="createConfigProductAttribute"/>
39+
</createData>
40+
41+
<createData entity="SimpleProduct" stepKey="createProduct02">
42+
<requiredEntity createDataKey="createCategory"/>
43+
</createData>
44+
45+
<createData entity="AssignProductToCategory" stepKey="assignTestCategoryToTestProduct">
46+
<requiredEntity createDataKey="createCategory"/>
47+
<requiredEntity createDataKey="createProduct01"/>
48+
<requiredEntity createDataKey="createProduct02"/>
49+
</createData>
50+
</before>
51+
<after>
52+
<magentoCLI command="config:set cataloginventory/options/show_out_of_stock 0" stepKey="setOutOfStockToNo"/>
53+
<deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/>
54+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
55+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
56+
<deleteData createDataKey="createProduct01" stepKey="deleteProduct1"/>
57+
<deleteData createDataKey="createProduct02" stepKey="deleteProduct2"/>
58+
</after>
59+
60+
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.custom_attributes[url_key]$$)}}" stepKey="goToStorefrontCreatedCategoryPage"/>
61+
<click selector="{{StorefrontCategoryMainSection.productAttributeName('attribute')}}" stepKey="selectProductAttribute"/>
62+
<wait time="2" stepKey="waitForLoad"/>
63+
<click selector="{{StorefrontCategoryMainSection.productAttributeOptionValue('option')}}" stepKey="selectProductAttributeOptionValue"/>
64+
</test>
65+
</tests>

0 commit comments

Comments
 (0)