Skip to content

Commit ba6cfa0

Browse files
Merge branch 2.2-develop into ENGCOM-4234-magento-magento2-21164
2 parents c7d3e55 + 4bb2bd0 commit ba6cfa0

File tree

51 files changed

+1020
-173
lines changed

Some content is hidden

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

51 files changed

+1020
-173
lines changed

app/code/Magento/Catalog/Model/Category.php

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,10 +1130,15 @@ public function reindex()
11301130
}
11311131
}
11321132
$productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID);
1133-
if (!$productIndexer->isScheduled()
1134-
&& (!empty($this->getAffectedProductIds()) || $this->dataHasChangedFor('is_anchor'))
1135-
) {
1136-
$productIndexer->reindexList($this->getPathIds());
1133+
1134+
if (!empty($this->getAffectedProductIds())
1135+
|| $this->dataHasChangedFor('is_anchor')
1136+
|| $this->dataHasChangedFor('is_active')) {
1137+
if (!$productIndexer->isScheduled()) {
1138+
$productIndexer->reindexList($this->getPathIds());
1139+
} else {
1140+
$productIndexer->invalidate();
1141+
}
11371142
}
11381143
}
11391144

@@ -1165,16 +1170,14 @@ public function getIdentities()
11651170
$identities[] = self::CACHE_TAG . '_' . $this->getId();
11661171
}
11671172

1168-
if ($this->hasDataChanges() || $this->isDeleted() || $this->dataHasChangedFor(self::KEY_INCLUDE_IN_MENU)) {
1169-
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();
1170-
}
1171-
1173+
$identities = $this->getCategoryRelationIdentities($identities);
1174+
11721175
if ($this->isObjectNew()) {
11731176
$identities[] = self::CACHE_TAG;
11741177
}
11751178
}
11761179

1177-
return $identities;
1180+
return array_unique($identities);
11781181
}
11791182

11801183
/**
@@ -1460,5 +1463,25 @@ public function setExtensionAttributes(\Magento\Catalog\Api\Data\CategoryExtensi
14601463
return $this->_setExtensionAttributes($extensionAttributes);
14611464
}
14621465

1466+
/**
1467+
* Return category relation identities.
1468+
*
1469+
* @param array $identities
1470+
* @return array
1471+
*/
1472+
private function getCategoryRelationIdentities(array $identities): array
1473+
{
1474+
if ($this->hasDataChanges() || $this->isDeleted() || $this->dataHasChangedFor(self::KEY_INCLUDE_IN_MENU)) {
1475+
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();
1476+
if ($this->dataHasChangedFor('is_anchor') || $this->dataHasChangedFor('is_active')) {
1477+
foreach ($this->getPathIds() as $id) {
1478+
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $id;
1479+
}
1480+
}
1481+
}
1482+
1483+
return $identities;
1484+
}
1485+
14631486
//@codeCoverageIgnoreEnd
14641487
}

app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontCategoryActionGroup.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
<see userInput="{{category.name}}" selector="{{StorefrontCategoryMainSection.categoryTitle}}" stepKey="assertCategoryName"/>
2020
<see userInput="{{productCount}}" selector="{{StorefrontCategoryMainSection.productCount}} span" stepKey="assertProductCount"/>
2121
</actionGroup>
22+
<!--Check category is empty-->
23+
<actionGroup name="StorefrontCheckEmptyCategoryActionGroup" extends="StorefrontCheckCategoryActionGroup">
24+
<remove keyForRemoval="assertProductCount"/>
25+
<amOnPage url="{{StorefrontCategoryPage.url(category.name)}}" before="checkUrl" stepKey="goToCategoryStorefront"/>
26+
<see selector="{{StorefrontCategoryMainSection.categoryEmptyMessage}}" userInput="We can't find products matching the selection." stepKey="seeCategoryEmpty"/>
27+
</actionGroup>
2228

2329
<!-- Check simple product on the category page -->
2430
<actionGroup name="StorefrontCheckCategorySimpleProduct">
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
10+
<page name="AdminProductUpdateAttributesPage" url="catalog/product_action_attribute/edit/" area="admin" module="Magento_Catalog">
11+
<section name="AdminUpdateAttributesHeaderSection"/>
12+
<section name="AdminUpdateAttributesWebsiteSection"/>
13+
</page>
14+
</pages>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
-->
88

99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminProductFiltersSection">
1212
<element name="FiltersButton" type="button" selector="#container > div > div.admin__data-grid-header > div:nth-child(1) > div.data-grid-filters-actions-wrap > div > button"/>
1313
<element name="clearFiltersButton" type="button" selector="//div[@class='admin__data-grid-header']//button[@class='action-tertiary action-clear']" timeout="10"/>
1414
<element name="NameInput" type="input" selector="input[name=name]"/>
1515
<element name="SkuInput" type="input" selector="input[name=sku]"/>
1616
<element name="Apply" type="button" selector="button[data-action=grid-filter-apply]" timeout="30"/>
17+
<element name="allCheckbox" type="checkbox" selector="div[data-role='grid-wrapper'] label[data-bind='attr: {for: ko.uid}']" timeout="30"/>
1718
</section>
1819
</sections>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<section name="AdminProductSEOSection">
1212
<element name="sectionHeader" type="button" selector="div[data-index='search-engine-optimization']" timeout="30"/>
1313
<element name="urlKeyInput" type="input" selector="input[name='product[url_key]']"/>
14+
<element name="useDefaultUrl" type="checkbox" selector="input[name='use_default[url_key]']"/>
1415
</section>
1516
</sections>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="AdminUpdateAttributesHeaderSection">
11+
<element name="saveButton" type="button" selector="button[data-ui-id='page-actions-toolbar-save-button']" timeout="30"/>
12+
</section>
13+
<section name="AdminUpdateAttributesWebsiteSection">
14+
<element name="website" type="button" selector="#attributes_update_tabs_websites"/>
15+
<element name="addProductToWebsite" type="checkbox" selector="#add-products-to-website-content .website-checkbox"/>
16+
</section>
17+
</sections>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
<element name="categoryPageProductImagePlaceholderSmall" type="text" selector=".products-grid img[src*='placeholder/small_image.jpg']"/>
2323
<element name="categoryPageProductImage" type="text" selector=".products-grid img[src*='/{{var1}}']" parameterized="true"/>
2424
<element name="categoryPageProductName" type="text" selector=".products.list.items.product-items li:nth-of-type({{line}}) .product-item-link" timeout="30" parameterized="true"/>
25+
<element name="categoryEmptyMessage" type="text" selector=".column.main .message.info.empty"/>
2526
</section>
2627
</sections>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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="StorefrontProductAvailableAfterEnablingSubCategoriesTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Show category products on storefront"/>
14+
<title value="Check that parent categories are showing products after enabling subcategories"/>
15+
<description value="Check that parent categories are showing products after enabling subcategories"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-13914"/>
18+
<useCaseId value="MAGETWO-96489"/>
19+
<group value="Catalog"/>
20+
</annotations>
21+
<before>
22+
<createData entity="_defaultCategory" stepKey="createCategory"/>
23+
<createData entity="SubCategoryWithParent" stepKey="createSubCategory">
24+
<requiredEntity createDataKey="createCategory"/>
25+
<field key="is_active">false</field>
26+
</createData>
27+
<createData entity="ApiSimpleProduct" stepKey="createSimpleProduct">
28+
<requiredEntity createDataKey="createSubCategory"/>
29+
</createData>
30+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
31+
</before>
32+
<after>
33+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
34+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
35+
<actionGroup ref="logout" stepKey="logout"/>
36+
</after>
37+
<!--Check anchor category is empty-->
38+
<actionGroup ref="StorefrontCheckEmptyCategoryActionGroup" stepKey="checkEmptyAnchorCategory">
39+
<argument name="category" value="$$createCategory$$"/>
40+
<argument name="productCount" value="0"/>
41+
</actionGroup>
42+
<!--Enable subcategory-->
43+
<actionGroup ref="AdminNavigateToCategoryInTree" stepKey="openCreatedSubCategory">
44+
<argument name="category" value="$$createSubCategory$$"/>
45+
</actionGroup>
46+
<click selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}" stepKey="enableCategory"/>
47+
<actionGroup ref="saveCategoryForm" stepKey="saveCategory"/>
48+
<!--Check created product in anchor category on storefront-->
49+
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="goToCategoryStorefront"/>
50+
<actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="seeCreatedProduct">
51+
<argument name="product" value="$$createSimpleProduct$$"/>
52+
</actionGroup>
53+
</test>
54+
</tests>

0 commit comments

Comments
 (0)