Skip to content

Commit 4f5aa1c

Browse files
[EngCom] Public Pull Requests - 2.3-develop
- merged latest code from mainline branch
2 parents 73c8d0a + 08fbdf1 commit 4f5aa1c

File tree

6 files changed

+146
-2
lines changed

6 files changed

+146
-2
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public function execute()
159159
if ($redirectBack === 'duplicate') {
160160
$product->unsetData('quantity_and_stock_status');
161161
$newProduct = $this->productCopier->copy($product);
162+
$this->checkUniqueAttributes($product);
162163
$this->messageManager->addSuccessMessage(__('You duplicated the product.'));
163164
}
164165
} catch (\Magento\Framework\Exception\LocalizedException $e) {
@@ -343,4 +344,25 @@ private function persistMediaData(ProductInterface $product, array $data)
343344

344345
return $data;
345346
}
347+
348+
/**
349+
* Check unique attributes and add error to message manager
350+
*
351+
* @param \Magento\Catalog\Model\Product $product
352+
*/
353+
private function checkUniqueAttributes(\Magento\Catalog\Model\Product $product)
354+
{
355+
$uniqueLabels = [];
356+
foreach ($product->getAttributes() as $attribute) {
357+
if ($attribute->getIsUnique() && $attribute->getIsUserDefined()
358+
&& $product->getData($attribute->getAttributeCode()) !== null
359+
) {
360+
$uniqueLabels[] = $attribute->getDefaultFrontendLabel();
361+
}
362+
}
363+
if ($uniqueLabels) {
364+
$uniqueLabels = implode('", "', $uniqueLabels);
365+
$this->messageManager->addErrorMessage(__('The value of attribute(s) "%1" must be unique', $uniqueLabels));
366+
}
367+
}
346368
}

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCustomProductAttributeWithDropdownFieldTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<severity value="CRITICAL"/>
1717
<testCaseId value="MC-10905"/>
1818
<group value="mtf_migrated"/>
19+
<skip>
20+
<issueId value="MC-15474"/>
21+
</skip>
1922
</annotations>
2023

2124
<before>

app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateAndSwitchProductType.xml

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<group value="catalog"/>
5555
<group value="mtf_migrated"/>
5656
<skip>
57-
<issueId value="MAGETWO-62808"/>
57+
<issueId value="MSI-2110"/>
5858
</skip>
5959
</annotations>
6060
<before>
@@ -83,4 +83,120 @@
8383
<argument name="optionName" value="$createConfigProductAttributeOption1.option[store_labels][1][label]$"/>
8484
</actionGroup>
8585
</test>
86+
<test name="AdminCreateSimpleProductSwitchToConfigurableTest" extends="AdminCreateSimpleProductSwitchToVirtualTest">
87+
<annotations>
88+
<features value="Catalog"/>
89+
<stories value="Product Type Switching"/>
90+
<title value="Admin should be able to switch a new product from simple to configurable"/>
91+
<description value="After selecting a simple product when adding Admin should be switch to configurable implicitly"/>
92+
<severity value="CRITICAL"/>
93+
<useCaseId value="MAGETWO-44165"/>
94+
<testCaseId value="MAGETWO-29398"/>
95+
<group value="catalog"/>
96+
<group value="mtf_migrated"/>
97+
<skip>
98+
<issueId value="MSI-2110"/>
99+
</skip>
100+
</annotations>
101+
<before>
102+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
103+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
104+
<requiredEntity createDataKey="createConfigProductAttribute"/>
105+
</createData>
106+
</before>
107+
<after>
108+
<deleteData stepKey="deleteAttribute" createDataKey="createConfigProductAttribute"/>
109+
</after>
110+
<actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="openProductFillForm">
111+
<argument name="productType" value="simple"/>
112+
</actionGroup>
113+
<!-- Create configurable product from simple product page-->
114+
<comment userInput="Create configurable product" stepKey="commentCreateProduct"/>
115+
<actionGroup ref="fillMainProductForm" stepKey="fillProductForm">
116+
<argument name="product" value="_defaultProduct"/>
117+
</actionGroup>
118+
<comment before="createConfiguration" stepKey="beforeCreateConfiguration" userInput="Adding Configuration to Product"/>
119+
<actionGroup ref="generateConfigurationsByAttributeCode" stepKey="createConfiguration" after="fillProductForm">
120+
<argument name="attributeCode" value="$$createConfigProductAttribute.attribute_code$$"/>
121+
</actionGroup>
122+
<actionGroup ref="saveConfiguredProduct" stepKey="saveProductForm"/>
123+
<see selector="{{AdminProductGridSection.productGridCell('2', 'Type')}}" userInput="Configurable Product" stepKey="seeProductTypeInGrid"/>
124+
<!-- Verify product on store front -->
125+
<comment userInput="Verify product on store front" stepKey="commentVerifyProductGrid"/>
126+
<actionGroup ref="VerifyOptionInProductStorefront" stepKey="verifyConfigurableOption" after="AssertProductInStorefrontProductPage">
127+
<argument name="attributeCode" value="$createConfigProductAttribute.default_frontend_label$"/>
128+
<argument name="optionName" value="$createConfigProductAttributeOption1.option[store_labels][1][label]$"/>
129+
</actionGroup>
130+
</test>
131+
<test name="AdminCreateDownloadableProductSwitchToConfigurableTest">
132+
<annotations>
133+
<features value="Catalog"/>
134+
<stories value="Product Type Switching"/>
135+
<title value="Admin should be able to switch a new product from downloadable to configurable"/>
136+
<description value="After selecting a downloadable product when adding Admin should be switch to configurable implicitly"/>
137+
<severity value="CRITICAL"/>
138+
<useCaseId value="MAGETWO-44165"/>
139+
<testCaseId value="MAGETWO-29398"/>
140+
<group value="catalog"/>
141+
<group value="mtf_migrated"/>
142+
<skip>
143+
<issueId value="MSI-2110"/>
144+
</skip>
145+
</annotations>
146+
<before>
147+
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/>
148+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
149+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
150+
<requiredEntity createDataKey="createConfigProductAttribute"/>
151+
</createData>
152+
</before>
153+
<after>
154+
<actionGroup ref="GoToProductCatalogPage" stepKey="goToProductCatalogPage"/>
155+
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteConfigurableProduct">
156+
<argument name="product" value="_defaultProduct"/>
157+
</actionGroup>
158+
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetSearch"/>
159+
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
160+
<deleteData stepKey="deleteAttribute" createDataKey="createConfigProductAttribute"/>
161+
<actionGroup ref="logout" stepKey="logout"/>
162+
</after>
163+
<!-- Create configurable product from downloadable product page-->
164+
<comment userInput="Create configurable product" stepKey="commentCreateProduct"/>
165+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
166+
<!-- Open Dropdown and select downloadable product option -->
167+
<comment stepKey="beforeOpenProductFillForm" userInput="Selecting Product from the Add Product Dropdown"/>
168+
<actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="openProductFillForm">
169+
<argument name="productType" value="downloadable"/>
170+
</actionGroup>
171+
<scrollTo selector="{{AdminProductDownloadableSection.sectionHeader}}" stepKey="scrollToDownloadableInfo" />
172+
<uncheckOption selector="{{AdminProductDownloadableSection.isDownloadableProduct}}" stepKey="checkIsDownloadable"/>
173+
<!-- Fill form for Downloadable Product Type -->
174+
<comment stepKey="beforeFillProductForm" userInput="Filling Product Form"/>
175+
<actionGroup ref="fillMainProductForm" stepKey="fillProductForm">
176+
<argument name="product" value="_defaultProduct"/>
177+
</actionGroup>
178+
<actionGroup ref="SetProductUrlKey" stepKey="setProductUrl">
179+
<argument name="product" value="_defaultProduct"/>
180+
</actionGroup>
181+
<comment before="createConfiguration" stepKey="beforeCreateConfiguration" userInput="Adding Configuration to Product"/>
182+
<actionGroup ref="generateConfigurationsByAttributeCode" stepKey="createConfiguration">
183+
<argument name="attributeCode" value="$$createConfigProductAttribute.attribute_code$$"/>
184+
</actionGroup>
185+
<actionGroup ref="saveConfiguredProduct" stepKey="saveProductForm"/>
186+
<!-- Check that product was added with implicit type change -->
187+
<comment stepKey="beforeVerify" userInput="Verify Product Type Assigned Correctly"/>
188+
<actionGroup ref="GoToProductCatalogPage" stepKey="goToProductCatalogPage"/>
189+
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetSearch"/>
190+
<actionGroup ref="filterProductGridByName" stepKey="searchForProduct">
191+
<argument name="product" value="_defaultProduct"/>
192+
</actionGroup>
193+
<see selector="{{AdminProductGridSection.productGridCell('2', 'Type')}}" userInput="Configurable Product" stepKey="seeProductTypeInGrid"/>
194+
<actionGroup ref="AssertProductInStorefrontProductPage" stepKey="assertProductInStorefrontProductPage">
195+
<argument name="product" value="_defaultProduct"/>
196+
</actionGroup>
197+
<actionGroup ref="VerifyOptionInProductStorefront" stepKey="verifyConfigurableOption">
198+
<argument name="attributeCode" value="$createConfigProductAttribute.default_frontend_label$"/>
199+
<argument name="optionName" value="$createConfigProductAttributeOption1.option[store_labels][1][label]$"/>
200+
</actionGroup>
201+
</test>
86202
</tests>

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Tree.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ public function assignCategory($parentCategoryName, $childCategoryName)
187187
*/
188188
public function expandAllCategories()
189189
{
190+
$this->getTemplateBlock()->waitLoader();
190191
$this->_rootElement->find($this->expandAll)->click();
192+
$this->getTemplateBlock()->waitLoader();
191193
}
192194
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function getSelectSortType()
4848
public function getSortType()
4949
{
5050
$content = $this->_rootElement->find($this->sorter)->getText();
51-
return explode("\n", $content);
51+
return array_values(array_filter(array_map('trim', explode("\n", $content))));
5252
}
5353

5454
/**

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForAssignedProducts" />
9797
</variation>
9898
<variation name="CreateCategoryEntityTestVariation5_Anchor_MostOfFields">
99+
<data name="tag" xsi:type="string">test_type:acceptance_test</data>
99100
<data name="description" xsi:type="string">Create anchor subcategory with all fields</data>
100101
<data name="addCategory" xsi:type="string">addSubcategory</data>
101102
<data name="category/data/parent_id/dataset" xsi:type="string">default_category</data>

0 commit comments

Comments
 (0)