Skip to content

Commit 22b0047

Browse files
author
Joan He
committed
Merge remote-tracking branch 'honey/MAGETWO-95213-mass-update-status' into BugFixPR
2 parents f7f4172 + 59fbdb4 commit 22b0047

File tree

7 files changed

+229
-1
lines changed

7 files changed

+229
-1
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
1515

1616
/**
17+
* Updates status for a batch of products.
1718
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1819
*/
1920
class MassStatus extends \Magento\Catalog\Controller\Adminhtml\Product implements HttpPostActionInterface
@@ -87,7 +88,7 @@ public function execute()
8788
$filterRequest = $this->getRequest()->getParam('filters', null);
8889
$status = (int) $this->getRequest()->getParam('status');
8990

90-
if (null !== $storeId && null !== $filterRequest) {
91+
if (null === $storeId && null !== $filterRequest) {
9192
$storeId = (isset($filterRequest['store_id'])) ? (int) $filterRequest['store_id'] : 0;
9293
}
9394

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,28 @@
275275
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="acceptStoreSwitchingMessage"/>
276276
<waitForPageLoad stepKey="waitForPageLoad"/>
277277
</actionGroup>
278+
279+
<!--Create a Simple Product-->
280+
<actionGroup name="createSimpleProductAndAddToWebsite">
281+
<arguments>
282+
<argument name="product"/>
283+
<argument name="website" type="string"/>
284+
</arguments>
285+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToCatalogProductGrid"/>
286+
<waitForPageLoad stepKey="waitForProductGrid"/>
287+
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickAddProductDropdown"/>
288+
<click selector="{{AdminProductGridActionSection.addSimpleProduct}}" stepKey="clickAddSimpleProduct"/>
289+
<fillField userInput="{{product.name}}" selector="{{AdminProductFormSection.productName}}" stepKey="fillProductName"/>
290+
<fillField userInput="{{product.sku}}" selector="{{AdminProductFormSection.productSku}}" stepKey="fillProductSKU"/>
291+
<fillField userInput="{{product.price}}" selector="{{AdminProductFormSection.productPrice}}" stepKey="fillProductPrice"/>
292+
<fillField userInput="{{product.quantity}}" selector="{{AdminProductFormSection.productQuantity}}" stepKey="fillProductQuantity"/>
293+
<click selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="openProductInWebsites"/>
294+
<click selector="{{ProductInWebsitesSection.website(website)}}" stepKey="selectWebsite"/>
295+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSave"/>
296+
<waitForLoadingMaskToDisappear stepKey="waitForProductPageSave"/>
297+
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSaveProductMessage"/>
298+
</actionGroup>
299+
278300
<actionGroup name="CreatedProductConnectToWebsite">
279301
<arguments>
280302
<argument name="website"/>

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,36 @@
434434
<data key="status">1</data>
435435
<requiredEntity type="product_extension_attribute">EavStock100</requiredEntity>
436436
</entity>
437+
<entity name="simpleProductForMassUpdate" type="product">
438+
<data key="sku" unique="suffix">testSku</data>
439+
<data key="type_id">simple</data>
440+
<data key="attribute_set_id">4</data>
441+
<data key="visibility">4</data>
442+
<data key="name" unique="suffix">massUpdateProductName</data>
443+
<data key="keyword">massUpdateProductName</data>
444+
<data key="price">123.00</data>
445+
<data key="urlKey" unique="suffix">masstesturlkey</data>
446+
<data key="status">1</data>
447+
<data key="quantity">100</data>
448+
<data key="weight">1</data>
449+
<requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity>
450+
<requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity>
451+
</entity>
452+
<entity name="simpleProductForMassUpdate2" type="product">
453+
<data key="sku" unique="suffix">testSku</data>
454+
<data key="type_id">simple</data>
455+
<data key="attribute_set_id">4</data>
456+
<data key="visibility">4</data>
457+
<data key="name" unique="suffix">massUpdateProductName</data>
458+
<data key="keyword">massUpdateProductName</data>
459+
<data key="price">123.00</data>
460+
<data key="urlKey" unique="suffix">masstesturlkey</data>
461+
<data key="status">1</data>
462+
<data key="quantity">100</data>
463+
<data key="weight">1</data>
464+
<requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity>
465+
<requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity>
466+
</entity>
437467
<entity name="ApiSimpleSingleQty" type="product2">
438468
<data key="sku" unique="suffix">api-simple-product</data>
439469
<data key="type_id">simple</data>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@
2828
<element name="priceOfFirstRow" type="text" selector="//tr[@data-repeat-index='0']//div[contains(., '{{var1}}')]" parameterized="true"/>
2929
<element name="AllProductsNotOfBundleType" type="text" selector="//td[5]/div[text() != 'Bundle Product']"/>
3030
<element name="attributeSetOfFirstRow" type="text" selector="//tr[@data-repeat-index='0']//div[contains(., '{{var1}}')]" parameterized="true"/>
31+
<element name="storeViewDropDown" type="multiselect" selector="//select[@name='store_id']" timeout="30"/>
32+
<element name="storeViewOption" type="multiselect" selector="//select[@name='store_id']/option[contains(text(),'{{var1}}')]" parameterized="true" timeout="30"/>
3133
</section>
3234
</sections>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<element name="firstRow" type="button" selector="tr.data-row:nth-of-type(1)"/>
2929
<element name="productGridCheckboxOnRow" type="checkbox" selector="//*[@id='container']//tr[{{row}}]/td[1]//input" parameterized="true"/>
3030
<element name="productGridNameProduct" type="input" selector="//tbody//tr//td//div[contains(., '{{var1}}')]" parameterized="true" timeout="30"/>
31+
<element name="productGridContentsOnRow" type="checkbox" selector="//*[@id='container']//tr[{{row}}]/td" parameterized="true"/>
3132
<element name="selectRowBasedOnName" type="input" selector="//td/div[text()='{{var1}}']" parameterized="true"/>
3233
</section>
3334
</sections>
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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="AdminMassUpdateProductStatusStoreViewScopeTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Mass update product status"/>
15+
<title value="Admin should be able to mass update product statuses in store view scope"/>
16+
<description value="Admin should be able to mass update product statuses in store view scope"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="MAGETWO-59361"/>
19+
<group value="Catalog"/>
20+
<group value="Product Attributes"/>
21+
</annotations>
22+
<before>
23+
<actionGroup ref="LoginActionGroup" stepKey="loginAsAdmin"/>
24+
25+
<!--Create Website -->
26+
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createAdditionalWebsite">
27+
<argument name="newWebsiteName" value="Second Website"/>
28+
<argument name="websiteCode" value="second_website"/>
29+
</actionGroup>
30+
31+
<!--Create Store -->
32+
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createNewStore">
33+
<argument name="website" value="Second Website"/>
34+
<argument name="storeGroupName" value="Second Store"/>
35+
<argument name="storeGroupCode" value="second_store"/>
36+
</actionGroup>
37+
38+
<!--Create Store view -->
39+
<amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/>
40+
<waitForPageLoad stepKey="waitForSystemStorePage"/>
41+
<click selector="{{AdminStoresMainActionsSection.createStoreViewButton}}" stepKey="createStoreViewButton"/>
42+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
43+
<waitForElementVisible selector="//legend[contains(., 'Store View Information')]" stepKey="waitForNewStorePageToOpen"/>
44+
<selectOption userInput="Second Store" selector="{{AdminNewStoreSection.storeGrpDropdown}}" stepKey="selectStoreGroup"/>
45+
<fillField userInput="Second Store View" selector="{{AdminNewStoreSection.storeNameTextField}}" stepKey="fillStoreViewName"/>
46+
<fillField userInput="second_store_view" selector="{{AdminNewStoreSection.storeCodeTextField}}" stepKey="fillStoreViewCode"/>
47+
<selectOption selector="{{AdminNewStoreSection.statusDropdown}}" userInput="1" stepKey="enableStoreViewStatus"/>
48+
<click selector="{{AdminNewStoreViewActionsSection.saveButton}}" stepKey="clickSaveStoreView" />
49+
<waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForModal" />
50+
<see selector="{{AdminConfirmationModalSection.title}}" userInput="Warning message" stepKey="seeWarning" />
51+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="dismissModal" />
52+
<waitForPageLoad stepKey="waitForPageLoad2" time="180" />
53+
<waitForElementVisible selector="{{AdminStoresGridSection.storeFilterTextField}}" time="150" stepKey="waitForPageReolad"/>
54+
<see userInput="You saved the store view." stepKey="seeSavedMessage" />
55+
56+
<!--Create a Simple Product 1 -->
57+
<actionGroup ref="createSimpleProductAndAddToWebsite" stepKey="createSimpleProduct1">
58+
<argument name="product" value="simpleProductForMassUpdate"/>
59+
<argument name="website" value="Second Website"/>
60+
</actionGroup>
61+
62+
<!--Create a Simple Product 2 -->
63+
<actionGroup ref="createSimpleProductAndAddToWebsite" stepKey="createSimpleProduct2">
64+
<argument name="product" value="simpleProductForMassUpdate2"/>
65+
<argument name="website" value="Second Website"/>
66+
</actionGroup>
67+
</before>
68+
<after>
69+
<!--Delete website -->
70+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteSecondWebsite">
71+
<argument name="websiteName" value="Second Website"/>
72+
</actionGroup>
73+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/>
74+
75+
<!--Delete Products -->
76+
<actionGroup ref="DeleteProductActionGroup" stepKey="deleteProduct1">
77+
<argument name="productName" value="simpleProductForMassUpdate.name"/>
78+
</actionGroup>
79+
<actionGroup ref="DeleteProductActionGroup" stepKey="deleteProduct2">
80+
<argument name="productName" value="simpleProductForMassUpdate2.name"/>
81+
</actionGroup>
82+
<actionGroup ref="logout" stepKey="amOnLogoutPage"/>
83+
</after>
84+
85+
<!-- Search and select products -->
86+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/>
87+
<waitForPageLoad stepKey="waitForProductIndexPageLoad"/>
88+
<actionGroup ref="searchProductGridByKeyword2" stepKey="searchByKeyword">
89+
<argument name="keyword" value="{{simpleProductForMassUpdate.keyword}}"/>
90+
</actionGroup>
91+
<actionGroup ref="sortProductsByIdDescending" stepKey="sortProductsByIdDescending"/>
92+
93+
<!-- Filter to Second Store View -->
94+
<actionGroup ref="AdminFilterStoreViewActionGroup" stepKey="filterStoreView" >
95+
<argument name="customStore" value="'Second Store View'" />
96+
</actionGroup>
97+
98+
<!-- Select Product 2 -->
99+
<click selector="{{AdminProductGridSection.productGridCheckboxOnRow('2')}}" stepKey="clickCheckbox2"/>
100+
101+
<!-- Mass update attributes -->
102+
<click selector="{{AdminProductGridSection.bulkActionDropdown}}" stepKey="clickDropdown"/>
103+
<click selector="{{AdminProductGridSection.bulkActionOption('Change status')}}" stepKey="clickOption"/>
104+
<click selector="{{AdminProductGridSection.bulkActionOption('Disable')}}" stepKey="clickDisabled"/>
105+
<waitForPageLoad stepKey="waitForBulkUpdatePage"/>
106+
107+
<!-- Verify Product Statuses -->
108+
<see selector="{{AdminProductGridSection.productGridContentsOnRow('1')}}" userInput="Enabled" stepKey="checkIfProduct1IsEnabled"/>
109+
<see selector="{{AdminProductGridSection.productGridContentsOnRow('2')}}" userInput="Disabled" stepKey="checkIfProduct2IsDisabled"/>
110+
111+
<!-- Filter to Default Store View -->
112+
<actionGroup ref="AdminFilterStoreViewActionGroup" stepKey="filterDefaultStoreView">
113+
<argument name="customStore" value="'Default'" />
114+
</actionGroup>
115+
116+
<!-- Verify Product Statuses -->
117+
<see selector="{{AdminProductGridSection.productGridContentsOnRow('1')}}" userInput="Enabled" stepKey="checkIfDefaultViewProduct1IsEnabled"/>
118+
<see selector="{{AdminProductGridSection.productGridContentsOnRow('2')}}" userInput="Enabled" stepKey="checkIfDefaultViewProduct2IsEnabled"/>
119+
120+
<!-- Assert on storefront default view -->
121+
<actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupDefault"/>
122+
<actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameAndDescriptionActionGroup" stepKey="searchByNameDefault">
123+
<argument name="name" value="{{simpleProductForMassUpdate.keyword}}"/>
124+
<argument name="description" value=""/>
125+
</actionGroup>
126+
<actionGroup ref="StorefrontCheckAdvancedSearchResultActionGroup" stepKey="StorefrontCheckAdvancedSearchResultDefault"/>
127+
<see userInput="2 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="seeInDefault"/>
128+
129+
<!-- Enable the product in Default store view -->
130+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex2"/>
131+
<waitForPageLoad stepKey="waitForProductIndexPageLoad2"/>
132+
<click selector="{{AdminProductGridSection.productGridCheckboxOnRow('1')}}" stepKey="clickCheckboxDefaultStoreView"/>
133+
<click selector="{{AdminProductGridSection.productGridCheckboxOnRow('2')}}" stepKey="clickCheckboxDefaultStoreView2"/>
134+
135+
<!-- Mass update attributes -->
136+
<click selector="{{AdminProductGridSection.bulkActionDropdown}}" stepKey="clickDropdownDefaultStoreView"/>
137+
<click selector="{{AdminProductGridSection.bulkActionOption('Change status')}}" stepKey="clickOptionDefaultStoreView"/>
138+
<click selector="{{AdminProductGridSection.bulkActionOption('Disable')}}" stepKey="clickDisabledDefaultStoreView"/>
139+
<waitForPageLoad stepKey="waitForBulkUpdatePageDefaultStoreView"/>
140+
<see selector="{{AdminProductGridSection.productGridContentsOnRow('1')}}" userInput="Disabled" stepKey="checkIfProduct2IsDisabledDefaultStoreView"/>
141+
142+
<!-- Assert on storefront default view -->
143+
<actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupDefault2"/>
144+
<actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameAndDescriptionActionGroup" stepKey="searchByNameDefault2">
145+
<argument name="name" value="{{simpleProductForMassUpdate.name}}"/>
146+
<argument name="description" value=""/>
147+
</actionGroup>
148+
<actionGroup ref="StorefrontCheckAdvancedSearchResultActionGroup" stepKey="StorefrontCheckAdvancedSearchResultDefault2"/>
149+
<see userInput="We can't find any items matching these search criteria." selector="{{StorefrontCatalogSearchAdvancedResultMainSection.message}}" stepKey="seeInDefault2"/>
150+
</test>
151+
</tests>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
<!-- Test XML Example -->
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminFilterStoreViewActionGroup">
12+
<arguments>
13+
<argument name="StoreGroup" defaultValue="_defaultStoreGroup"/>
14+
<argument name="customStore" defaultValue="customStore.name"/>
15+
</arguments>
16+
<click selector="{{AdminProductFiltersSection.filter}}" stepKey="ClickOnFilter"/>
17+
<click selector="{{AdminProductFiltersSection.storeViewDropDown}}" stepKey="ClickOnStoreViewDropDown"/>
18+
<click selector="{{AdminProductFiltersSection.storeViewOption(customStore)}}" stepKey="ClickOnStoreViewOption"/>
19+
<click selector="{{AdminProductFiltersSection.applyFilters}}" stepKey="ClickOnApplyFilters"/>
20+
</actionGroup>
21+
</actionGroups>

0 commit comments

Comments
 (0)