Skip to content

Commit a6ed46a

Browse files
authored
Merge pull request #2301 from magento-panda/PANDA-FIXES-2.2.4
Fixed issues: - MAGETWO-89248 Category navigation menu is not updated after moving sub category to the same level as parent
2 parents fe16964 + 5c05a49 commit a6ed46a

11 files changed

+256
-2
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,13 @@ public function getIdentities()
11371137
{
11381138
$identities = [];
11391139
if ($this->getId()) {
1140-
$identities[] = self::CACHE_TAG . '_' . $this->getId();
1140+
if ($this->getAffectedCategoryIds()) {
1141+
foreach (array_unique($this->getAffectedCategoryIds()) as $affectedCategoryId) {
1142+
$identities[] = self::CACHE_TAG . '_' . $affectedCategoryId;
1143+
}
1144+
} else {
1145+
$identities[] = self::CACHE_TAG . '_' . $this->getId();
1146+
}
11411147

11421148
if ($this->hasDataChanges() || $this->isDeleted() || $this->dataHasChangedFor(self::KEY_INCLUDE_IN_MENU)) {
11431149
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();

app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,20 @@ public function testGetIdentities()
519519

520520
//Now because ID is set we can get some
521521
$category->setId(42);
522-
522+
523523
$this->assertNotEmpty($category->getIdentities());
524524
}
525+
526+
/**
527+
* @return void
528+
*/
529+
public function testGetIdentitiesWithAffectedCategories()
530+
{
531+
$category = $this->getCategoryModel();
532+
$expectedIdentities = ['cat_c_1', 'cat_c_2', 'cat_c_3', 'cat_c_p_1'];
533+
$category->setId(1);
534+
$category->setAffectedCategoryIds([1,2,3]);
535+
536+
$this->assertEquals($expectedIdentities, $category->getIdentities());
537+
}
525538
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="CheckItemInLayeredNavigationActionGroup">
12+
<arguments>
13+
<argument name="itemType"/>
14+
<argument name="itemName"/>
15+
</arguments>
16+
<conditionalClick selector="{{StorefrontCategorySidebarSection.filterOptionsTitle('itemType')}}" dependentSelector="{{StorefrontCategorySidebarSection.filterOptions}}" visible="false" stepKey="expandFilterOptions"/>
17+
</actionGroup>
18+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="MoveCategoryActionGroup">
12+
<arguments>
13+
<argument name="childCategory"/>
14+
<argument name="parentCategory"/>
15+
</arguments>
16+
<click stepKey="expandAllCategoriesTree" selector="{{AdminCategorySidebarTreeSection.expandAll}}"/>
17+
<waitForAjaxLoad stepKey="waitForCategoriesExpand"/>
18+
<dragAndDrop selector1="{{AdminCategorySidebarTreeSection.category('childCategory')}}" selector2="{{AdminCategorySidebarTreeSection.category('parentCategory')}}" stepKey="moveCategory"/>
19+
<waitForElementVisible selector="{{AdminCategoryWarningMessagesPopupSection.warningMessage}}" stepKey="waitForWarningMessageVisible"/>
20+
<click selector="{{AdminCategoryWarningMessagesPopupSection.okButton}}" stepKey="clickOkButtonOnWarningPopup"/>
21+
</actionGroup>
22+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="OpenProductFromCategoryPageActionGroup">
12+
<arguments>
13+
<argument name="category"/>
14+
<argument name="product"/>
15+
</arguments>
16+
<!-- Go to storefront category page -->
17+
<amOnPage url="{{StorefrontCategoryPage.url(category.custom_attributes[url_path])}}" stepKey="navigateToCategoryPage"/>
18+
<!-- Go to storefront product page -->
19+
<click selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo(product.name)}}" stepKey="openProductPage"/>
20+
<waitForAjaxLoad stepKey="waitForImageLoader"/>
21+
</actionGroup>
22+
</actionGroups>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/AdminCategorySidebarTreeSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<section name="AdminCategorySidebarTreeSection">
1212
<element name="collapseAll" type="button" selector=".tree-actions a:first-child"/>
1313
<element name="expandAll" type="button" selector=".tree-actions a:last-child"/>
14+
<element name="category" type="button" selector="//span[contains(text(),'{{var1}}')]" parameterized="true"/>
1415
</section>
1516
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="AdminCategoryWarningMessagesPopupSection">
12+
<element name="warningMessage" type="text" selector=".modal-inner-wrap .modal-content .message.message-notice"/>
13+
<element name="cancelButton" type="button" selector=".modal-inner-wrap .action-secondary"/>
14+
<element name="okButton" type="button" selector=".modal-inner-wrap .action-primary" timeout="30"/>
15+
</section>
16+
</sections>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/StorefrontCategoryMainSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<section name="StorefrontCategoryMainSection">
1212
<element name="CategoryTitle" type="text" selector="#page-title-heading span"/>
1313
<element name="ProductItemInfo" type="button" selector=".product-item-info"/>
14+
<element name="specifiedProductItemInfo" type="button" selector="//a[@class='product-item-link'][contains(text(), '{{var1}}')]" parameterized="true"/>
1415
<element name="AddToCartBtn" type="button" selector="button.action.tocart.primary"/>
1516
<element name="SuccessMsg" type="button" selector="div.message-success"/>
1617
<element name="productCount" type="text" selector="#toolbar-amount"/>
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+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="StorefrontCategorySidebarSection">
12+
<element name="filterOptionsTitle" type="text" selector="//div[@class='filter-options-title' and contains(text(), '{{var1}}')]" parameterized="true"/>
13+
<element name="filterOptions" type="text" selector=".filter-options-content .items"/>
14+
<element name="filterOption" type="text" selector=".filter-options-content .item"/>
15+
<element name="optionQty" type="text" selector=".filter-options-content .item .count"/>
16+
</section>
17+
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="StorefrontNavigationSection">
12+
<element name="topCategory" type="button" selector="//a[contains(@class,'level-top')]/span[contains(text(),'{{var1}}')]" parameterized="true"/>
13+
<element name="subCategory" type="button" selector="//ul[contains(@class,'submenu')]//span[contains(text(),'{{var1}}')]" parameterized="true"/>
14+
<element name="breadcrumbs" type="textarea" selector=".items"/>
15+
</section>
16+
</sections>

0 commit comments

Comments
 (0)