Skip to content

Commit 3ee05a4

Browse files
authored
Merge pull request #4793 from magento-epam/EPAM-PR-73
- Fixed [FT] Not pass functional test \Magento\Catalog\Test\TestCase\Product\ProductTypeSwitchingOnUpdateTest - Fixed [GITHUB] Inconsistent CSV file Import error: #7495 - Fixed Incorrect behavior in the category menu on the Storefront
2 parents 0a390bb + 102f608 commit 3ee05a4

File tree

14 files changed

+692
-10
lines changed

14 files changed

+692
-10
lines changed

app/code/Magento/Catalog/Plugin/Block/Topmenu.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Catalog\Plugin\Block;
79

810
use Magento\Catalog\Model\Category;
@@ -156,12 +158,13 @@ private function getCurrentCategory()
156158
*/
157159
private function getCategoryAsArray($category, $currentCategory, $isParentActive)
158160
{
161+
$categoryId = $category->getId();
159162
return [
160163
'name' => $category->getName(),
161-
'id' => 'category-node-' . $category->getId(),
164+
'id' => 'category-node-' . $categoryId,
162165
'url' => $this->catalogCategory->getCategoryUrl($category),
163-
'has_active' => in_array((string)$category->getId(), explode('/', $currentCategory->getPath()), true),
164-
'is_active' => $category->getId() == $currentCategory->getId(),
166+
'has_active' => in_array((string)$categoryId, explode('/', (string)$currentCategory->getPath()), true),
167+
'is_active' => $categoryId == $currentCategory->getId(),
165168
'is_category' => true,
166169
'is_parent_active' => $isParentActive
167170
];
@@ -193,4 +196,22 @@ protected function getCategoryTree($storeId, $rootId)
193196

194197
return $collection;
195198
}
199+
200+
/**
201+
* Add active
202+
*
203+
* @param \Magento\Theme\Block\Html\Topmenu $subject
204+
* @param string[] $result
205+
* @return string[]
206+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
207+
*/
208+
public function afterGetCacheKeyInfo(\Magento\Theme\Block\Html\Topmenu $subject, array $result)
209+
{
210+
$activeCategory = $this->getCurrentCategory();
211+
if ($activeCategory) {
212+
$result[] = Category::CACHE_TAG . '_' . $activeCategory->getId();
213+
}
214+
215+
return $result;
216+
}
196217
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@
9999
<attachFile selector="{{AdminCategoryContentSection.uploadImageFile}}" userInput="{{image.file}}" stepKey="uploadFile"/>
100100
<waitForAjaxLoad time="30" stepKey="waitForAjaxUpload"/>
101101
<waitForLoadingMaskToDisappear stepKey="waitForLoading"/>
102-
<see selector="{{AdminCategoryContentSection.imageFileName}}" userInput="{{image.file}}" stepKey="seeImage"/>
102+
<grabTextFrom selector="{{AdminCategoryContentSection.imageFileName}}" stepKey="grabCategoryFileName"/>
103+
<assertRegExp stepKey="assertEquals" message="pass">
104+
<expectedResult type="string">/magento-logo(_[0-9]+)*?\.png$/</expectedResult>
105+
<actualResult type="variable">grabCategoryFileName</actualResult>
106+
</assertRegExp>
103107
</actionGroup>
104108

105109
<!-- Remove image from category -->
@@ -128,7 +132,11 @@
128132
<conditionalClick selector="{{AdminCategoryContentSection.sectionHeader}}" dependentSelector="{{AdminCategoryContentSection.uploadButton}}" visible="false" stepKey="openContentSection"/>
129133
<waitForPageLoad stepKey="waitForPageLoad"/>
130134
<waitForElementVisible selector="{{AdminCategoryContentSection.uploadButton}}" stepKey="seeImageSectionIsReady"/>
131-
<see selector="{{AdminCategoryContentSection.imageFileName}}" userInput="{{image.file}}" stepKey="seeImage"/>
135+
<grabTextFrom selector="{{AdminCategoryContentSection.imageFileName}}" stepKey="grabCategoryFileName"/>
136+
<assertRegExp stepKey="assertEquals" message="pass">
137+
<expectedResult type="string">/magento-logo(_[0-9]+)*?\.png$/</expectedResult>
138+
<actualResult type="variable">grabCategoryFileName</actualResult>
139+
</assertRegExp>
132140
</actionGroup>
133141

134142
<!-- Action to navigate to Media Gallery. Used in tests to cleanup uploaded images -->

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
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="categoryHighlighted" type="text" selector="//div[@id='store.menu']//span[contains(text(),'{{name}}')]/ancestor::li" parameterized="true" timeout="30"/>
15+
<element name="categoryNotHighlighted" type="text" selector="ul[id=\'ui-id-2\'] li[class~=\'active\']" timeout="30"/>
1416
<element name="categoryTreeRoot" type="text" selector="div.x-tree-root-node>li.x-tree-node:first-of-type>div.x-tree-node-el:first-of-type" timeout="30"/>
1517
<element name="categoryInTree" type="text" selector="//a/span[contains(text(), '{{name}}')]" parameterized="true" timeout="30"/>
1618
<element name="categoryInTreeUnderRoot" type="text" selector="//li/ul/li[@class='x-tree-node']/div/a/span[contains(text(), '{{name}}')]" parameterized="true"/>
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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="AdminVirtualProductTypeSwitchingToDownloadableProductTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Product type switching"/>
15+
<title value="Virtual product type switching on editing to Downloadable product"/>
16+
<description value="Virtual product type switching on editing to Downloadable product"/>
17+
<testCaseId value="MC-17954"/>
18+
<useCaseId value="MAGETWO-44170"/>
19+
<severity value="MAJOR"/>
20+
<group value="catalog"/>
21+
</annotations>
22+
<before>
23+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
24+
<!--Create product-->
25+
<comment userInput="Create product" stepKey="commentCreateProduct"/>
26+
<createData entity="VirtualProduct" stepKey="createProduct"/>
27+
</before>
28+
<after>
29+
<!--Delete product-->
30+
<comment userInput="Delete product" stepKey="commentDeleteProduct"/>
31+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
32+
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearProductFilters"/>
33+
<actionGroup ref="logout" stepKey="logout"/>
34+
</after>
35+
<!--Change product type to Downloadable-->
36+
<comment userInput="Change product type to Downloadable" stepKey="commentCreateDownloadable"/>
37+
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="gotToDownloadableProductPage"/>
38+
<waitForPageLoad stepKey="waitForDownloadableProductPageLoad"/>
39+
<actionGroup ref="AdminAddDownloadableLinkInformationActionGroup" stepKey="addDownloadableLinkInformation"/>
40+
<checkOption selector="{{AdminProductDownloadableSection.isLinksPurchasedSeparately}}" stepKey="checkOptionPurchaseSeparately"/>
41+
<actionGroup ref="addDownloadableProductLinkWithMaxDownloads" stepKey="addDownloadableProductLink">
42+
<argument name="link" value="downloadableLinkWithMaxDownloads"/>
43+
</actionGroup>
44+
<actionGroup ref="saveProductForm" stepKey="saveDownloadableProductForm"/>
45+
<!--Assert downloadable product on Admin product page grid-->
46+
<comment userInput="Assert configurable product in Admin product page grid" stepKey="commentAssertDownloadableProductOnAdmin"/>
47+
<amOnPage url="{{AdminCatalogProductPage.url}}" stepKey="goToCatalogProductPage"/>
48+
<actionGroup ref="filterProductGridBySku2" stepKey="filterProductGridBySku">
49+
<argument name="sku" value="$$createProduct.sku$$"/>
50+
</actionGroup>
51+
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="$$createProduct.name$$" stepKey="seeDownloadableProductNameInGrid"/>
52+
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Downloadable Product" stepKey="seeDownloadableProductTypeInGrid"/>
53+
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearDownloadableProductFilters"/>
54+
<!--Assert downloadable product on storefront-->
55+
<comment userInput="Assert downloadable product on storefront" stepKey="commentAssertDownloadableProductOnStorefront"/>
56+
<amOnPage url="{{StorefrontProductPage.url($$createProduct.name$$)}}" stepKey="openDownloadableProductPage"/>
57+
<waitForPageLoad stepKey="waitForStorefrontDownloadableProductPageLoad"/>
58+
<see userInput="IN STOCK" selector="{{StorefrontProductInfoMainSection.productStockStatus}}" stepKey="assertDownloadableProductInStock"/>
59+
<scrollTo selector="{{StorefrontDownloadableProductSection.downloadableLinkBlock}}" stepKey="scrollToLinksInStorefront"/>
60+
<seeElement selector="{{StorefrontDownloadableProductSection.downloadableLinkLabel(downloadableLinkWithMaxDownloads.title)}}" stepKey="seeDownloadableLink" />
61+
</test>
62+
<test name="AdminDownloadableProductTypeSwitchingToSimpleProductTest" extends="AdminVirtualProductTypeSwitchingToDownloadableProductTest">
63+
<annotations>
64+
<features value="Catalog"/>
65+
<stories value="Product type switching"/>
66+
<title value="Downloadable product type switching on editing to Simple product"/>
67+
<description value="Downloadable product type switching on editing to Simple product"/>
68+
<testCaseId value="MC-17955"/>
69+
<useCaseId value="MAGETWO-44170"/>
70+
<severity value="MAJOR"/>
71+
<group value="catalog"/>
72+
</annotations>
73+
<!--Change product type to Simple-->
74+
<comment userInput="Change product type to Simple Product" stepKey="commentCreateSimple"/>
75+
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="gotToProductPage"/>
76+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
77+
<actionGroup ref="AdminAddDownloadableLinkInformationActionGroup" stepKey="addDownloadableLinkInformation"/>
78+
<selectOption selector="{{AdminProductFormSection.productWeightSelect}}" userInput="This item has weight" stepKey="selectWeightForProduct"/>
79+
<actionGroup ref="saveProductForm" stepKey="saveProductForm"/>
80+
<!--Assert simple product on Admin product page grid-->
81+
<comment userInput="Assert simple product in Admin product page grid" stepKey="commentAssertProductOnAdmin"/>
82+
<amOnPage url="{{AdminCatalogProductPage.url}}" stepKey="goToCatalogSimpleProductPage"/>
83+
<actionGroup ref="filterProductGridBySku2" stepKey="filterSimpleProductGridBySku">
84+
<argument name="sku" value="$$createProduct.sku$$"/>
85+
</actionGroup>
86+
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="$$createProduct.name$$" stepKey="seeSimpleProductNameInGrid"/>
87+
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Simple Product" stepKey="seeSimpleProductTypeInGrid"/>
88+
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearSimpleProductFilters"/>
89+
<!--Assert simple product on storefront-->
90+
<comment userInput="Assert simple product on storefront" stepKey="commentAssertSimpleProductOnStorefront"/>
91+
<amOnPage url="{{StorefrontProductPage.url($$createProduct.name$$)}}" stepKey="openSimpleProductPage"/>
92+
<waitForPageLoad stepKey="waitForStorefrontSimpleProductPageLoad"/>
93+
<see userInput="IN STOCK" selector="{{StorefrontProductInfoMainSection.productStockStatus}}" stepKey="assertSimpleProductInStock"/>
94+
<dontSeeElement selector="{{StorefrontDownloadableProductSection.downloadableLinkLabel(downloadableLinkWithMaxDownloads.title)}}" stepKey="dontSeeDownloadableLink" />
95+
</test>
96+
</tests>
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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="StorefrontCategoryHighlightedAndProductDisplayedTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Category"/>
15+
<title value="Сheck that current category is highlighted and all products displayed for it"/>
16+
<description value="Сheck that current category is highlighted and all products displayed for it"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-19626"/>
19+
<useCaseId value="MAGETWO-98748"/>
20+
<group value="Catalog"/>
21+
</annotations>
22+
<before>
23+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
24+
<createData entity="SimpleSubCategory" stepKey="category1"/>
25+
<createData entity="SimpleSubCategory" stepKey="category2"/>
26+
<createData entity="SimpleSubCategory" stepKey="category3"/>
27+
<createData entity="SimpleSubCategory" stepKey="category4"/>
28+
<createData entity="SimpleProduct" stepKey="product1">
29+
<requiredEntity createDataKey="category1"/>
30+
</createData>
31+
<createData entity="SimpleProduct" stepKey="product2">
32+
<requiredEntity createDataKey="category1"/>
33+
</createData>
34+
<createData entity="SimpleProduct" stepKey="product3">
35+
<requiredEntity createDataKey="category2"/>
36+
</createData>
37+
<createData entity="SimpleProduct" stepKey="product4">
38+
<requiredEntity createDataKey="category2"/>
39+
</createData>
40+
</before>
41+
<after>
42+
<deleteData createDataKey="product1" stepKey="deleteProduct1"/>
43+
<deleteData createDataKey="product2" stepKey="deleteProduct2"/>
44+
<deleteData createDataKey="product3" stepKey="deleteProduct3"/>
45+
<deleteData createDataKey="product4" stepKey="deleteProduct4"/>
46+
<deleteData createDataKey="category1" stepKey="deleteCategory1"/>
47+
<deleteData createDataKey="category2" stepKey="deleteCategory2"/>
48+
<deleteData createDataKey="category3" stepKey="deleteCategory3"/>
49+
<deleteData createDataKey="category4" stepKey="deleteCategory4"/>
50+
<actionGroup ref="logout" stepKey="logout"/>
51+
</after>
52+
<!--Open Storefront home page-->
53+
<comment userInput="Open Storefront home page" stepKey="openStorefrontHomePage"/>
54+
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToStorefrontHomePage"/>
55+
<waitForPageLoad stepKey="waitForSimpleProductPage"/>
56+
<!--Click on first category-->
57+
<comment userInput="Click on first category" stepKey="openFirstCategoryPage"/>
58+
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$category1.name$$)}}" stepKey="clickCategory1Name"/>
59+
<waitForPageLoad stepKey="waitForCategory1Page"/>
60+
<!--Check if current category is highlighted and the others are not-->
61+
<comment userInput="Check if current category is highlighted and the others are not" stepKey="checkCateg1NameIsHighlighted"/>
62+
<grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$category1.name$$)}}" userInput="class" stepKey="grabCategory1Class"/>
63+
<assertContains expectedType="string" expected="active" actual="$grabCategory1Class" stepKey="assertCategory1IsHighlighted"/>
64+
<executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="highlightedAmount"/>
65+
<assertEquals expectedType="int" expected="1" actual="$highlightedAmount" stepKey="assertRestCategories1IsNotHighlighted"/>
66+
<!--See products in the category page-->
67+
<comment userInput="See products in the category page" stepKey="seeProductsInCategoryPage"/>
68+
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($product1.name$)}}" stepKey="seeProduct1InCategoryPage"/>
69+
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($product2.name$)}}" stepKey="seeProduct2InCategoryPage"/>
70+
<!--Click on second category-->
71+
<comment userInput="Click on second category" stepKey="openSecondCategoryPage"/>
72+
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$category2.name$$)}}" stepKey="clickCategory2Name"/>
73+
<waitForPageLoad stepKey="waitForCategory2Page"/>
74+
<!--Check if current category is highlighted and the others are not-->
75+
<comment userInput="Check if current category is highlighted and the others are not" stepKey="checkCateg2NameIsHighlighted"/>
76+
<grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$category2.name$$)}}" userInput="class" stepKey="grabCategory2Class"/>
77+
<assertContains expectedType="string" expected="active" actual="$grabCategory2Class" stepKey="assertCategory2IsHighlighted"/>
78+
<executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="highlightedAmount2"/>
79+
<assertEquals expectedType="int" expected="1" actual="$highlightedAmount2" stepKey="assertRestCategories1IsNotHighlighted2"/>
80+
<!--Assert products in second category page-->
81+
<comment userInput="Assert products in second category page" stepKey="commentAssertProducts"/>
82+
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($product3.name$)}}" stepKey="seeProduct3InCategoryPage"/>
83+
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($product4.name$)}}" stepKey="seeProduct4InCategoryPage"/>
84+
</test>
85+
</tests>

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
141141
const COL_PRODUCT_WEBSITES = '_product_websites';
142142

143143
/**
144-
* Media gallery attribute code.
144+
* Attribute code for media gallery.
145145
*/
146146
const MEDIA_GALLERY_ATTRIBUTE_CODE = 'media_gallery';
147147

@@ -151,12 +151,12 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
151151
const COL_MEDIA_IMAGE = '_media_image';
152152

153153
/**
154-
* Inventory use config.
154+
* Inventory use config label.
155155
*/
156156
const INVENTORY_USE_CONFIG = 'Use Config';
157157

158158
/**
159-
* Inventory use config prefix.
159+
* Prefix for inventory use config.
160160
*/
161161
const INVENTORY_USE_CONFIG_PREFIX = 'use_config_';
162162

@@ -1886,6 +1886,7 @@ protected function _saveProducts()
18861886

18871887
return $this;
18881888
}
1889+
//phpcs:enable Generic.Metrics.NestingLevel
18891890

18901891
/**
18911892
* Prepare array with image states (visible or hidden from product page)
@@ -2736,8 +2737,6 @@ protected function _saveValidatedBunches()
27362737
try {
27372738
$rowData = $source->current();
27382739
} catch (\InvalidArgumentException $e) {
2739-
$this->addRowError($e->getMessage(), $this->_processedRowsCount);
2740-
$this->_processedRowsCount++;
27412740
$source->next();
27422741
continue;
27432742
}

0 commit comments

Comments
 (0)