Skip to content

Commit

Permalink
Merge pull request #3763 from magento-tsg/2.2-develop-pr77
Browse files Browse the repository at this point in the history
[TSG] Backporting for 2.2 (pr77) (2.2)
  • Loading branch information
sivaschenko authored Feb 16, 2019
2 parents 7390453 + 22ff5a6 commit e12277e
Show file tree
Hide file tree
Showing 44 changed files with 942 additions and 165 deletions.
41 changes: 32 additions & 9 deletions app/code/Magento/Catalog/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -1130,10 +1130,15 @@ public function reindex()
}
}
$productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID);
if (!$productIndexer->isScheduled()
&& (!empty($this->getAffectedProductIds()) || $this->dataHasChangedFor('is_anchor'))
) {
$productIndexer->reindexList($this->getPathIds());

if (!empty($this->getAffectedProductIds())
|| $this->dataHasChangedFor('is_anchor')
|| $this->dataHasChangedFor('is_active')) {
if (!$productIndexer->isScheduled()) {
$productIndexer->reindexList($this->getPathIds());
} else {
$productIndexer->invalidate();
}
}
}

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

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

$identities = $this->getCategoryRelationIdentities($identities);

if ($this->isObjectNew()) {
$identities[] = self::CACHE_TAG;
}
}

return $identities;
return array_unique($identities);
}

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

/**
* Return category relation identities.
*
* @param array $identities
* @return array
*/
private function getCategoryRelationIdentities(array $identities): array
{
if ($this->hasDataChanges() || $this->isDeleted() || $this->dataHasChangedFor(self::KEY_INCLUDE_IN_MENU)) {
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();
if ($this->dataHasChangedFor('is_anchor') || $this->dataHasChangedFor('is_active')) {
foreach ($this->getPathIds() as $id) {
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $id;
}
}
}

return $identities;
}

//@codeCoverageIgnoreEnd
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
<see userInput="{{category.name}}" selector="{{StorefrontCategoryMainSection.categoryTitle}}" stepKey="assertCategoryName"/>
<see userInput="{{productCount}}" selector="{{StorefrontCategoryMainSection.productCount}} span" stepKey="assertProductCount"/>
</actionGroup>
<!--Check category is empty-->
<actionGroup name="StorefrontCheckEmptyCategoryActionGroup" extends="StorefrontCheckCategoryActionGroup">
<remove keyForRemoval="assertProductCount"/>
<amOnPage url="{{StorefrontCategoryPage.url(category.name)}}" before="checkUrl" stepKey="goToCategoryStorefront"/>
<see selector="{{StorefrontCategoryMainSection.categoryEmptyMessage}}" userInput="We can't find products matching the selection." stepKey="seeCategoryEmpty"/>
</actionGroup>

<!-- Check simple product on the category page -->
<actionGroup name="StorefrontCheckCategorySimpleProduct">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
<page name="AdminProductUpdateAttributesPage" url="catalog/product_action_attribute/edit/" area="admin" module="Magento_Catalog">
<section name="AdminUpdateAttributesHeaderSection"/>
<section name="AdminUpdateAttributesWebsiteSection"/>
</page>
</pages>
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminProductFiltersSection">
<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"/>
<element name="clearFiltersButton" type="button" selector="//div[@class='admin__data-grid-header']//button[@class='action-tertiary action-clear']" timeout="10"/>
<element name="NameInput" type="input" selector="input[name=name]"/>
<element name="SkuInput" type="input" selector="input[name=sku]"/>
<element name="Apply" type="button" selector="button[data-action=grid-filter-apply]" timeout="30"/>
<element name="allCheckbox" type="checkbox" selector="div[data-role='grid-wrapper'] label[data-bind='attr: {for: ko.uid}']" timeout="30"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<section name="AdminProductSEOSection">
<element name="sectionHeader" type="button" selector="div[data-index='search-engine-optimization']" timeout="30"/>
<element name="urlKeyInput" type="input" selector="input[name='product[url_key]']"/>
<element name="useDefaultUrl" type="checkbox" selector="input[name='use_default[url_key]']"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminUpdateAttributesHeaderSection">
<element name="saveButton" type="button" selector="button[data-ui-id='page-actions-toolbar-save-button']" timeout="30"/>
</section>
<section name="AdminUpdateAttributesWebsiteSection">
<element name="website" type="button" selector="#attributes_update_tabs_websites"/>
<element name="addProductToWebsite" type="checkbox" selector="#add-products-to-website-content .website-checkbox"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
<element name="categoryPageProductImagePlaceholderSmall" type="text" selector=".products-grid img[src*='placeholder/small_image.jpg']"/>
<element name="categoryPageProductImage" type="text" selector=".products-grid img[src*='/{{var1}}']" parameterized="true"/>
<element name="categoryPageProductName" type="text" selector=".products.list.items.product-items li:nth-of-type({{line}}) .product-item-link" timeout="30" parameterized="true"/>
<element name="categoryEmptyMessage" type="text" selector=".column.main .message.info.empty"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?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="StorefrontProductAvailableAfterEnablingSubCategoriesTest">
<annotations>
<features value="Catalog"/>
<stories value="Show category products on storefront"/>
<title value="Check that parent categories are showing products after enabling subcategories"/>
<description value="Check that parent categories are showing products after enabling subcategories"/>
<severity value="MAJOR"/>
<testCaseId value="MC-13914"/>
<useCaseId value="MAGETWO-96489"/>
<group value="Catalog"/>
</annotations>
<before>
<createData entity="_defaultCategory" stepKey="createCategory"/>
<createData entity="SubCategoryWithParent" stepKey="createSubCategory">
<requiredEntity createDataKey="createCategory"/>
<field key="is_active">false</field>
</createData>
<createData entity="ApiSimpleProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createSubCategory"/>
</createData>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
</before>
<after>
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<actionGroup ref="logout" stepKey="logout"/>
</after>
<!--Check anchor category is empty-->
<actionGroup ref="StorefrontCheckEmptyCategoryActionGroup" stepKey="checkEmptyAnchorCategory">
<argument name="category" value="$$createCategory$$"/>
<argument name="productCount" value="0"/>
</actionGroup>
<!--Enable subcategory-->
<actionGroup ref="AdminNavigateToCategoryInTree" stepKey="openCreatedSubCategory">
<argument name="category" value="$$createSubCategory$$"/>
</actionGroup>
<click selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}" stepKey="enableCategory"/>
<actionGroup ref="saveCategoryForm" stepKey="saveCategory"/>
<!--Check created product in anchor category on storefront-->
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="goToCategoryStorefront"/>
<actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="seeCreatedProduct">
<argument name="product" value="$$createSimpleProduct$$"/>
</actionGroup>
</test>
</tests>
Loading

0 comments on commit e12277e

Please sign in to comment.