Skip to content

Commit 08fbdf1

Browse files
authored
Merge pull request #3949 from magento-epam/EPAM-PR-44
- fixed MAGETWO-51459: CreateCategoryEntityTest and VisualMerchandiser/RemoveProductTest fail when system message about indexers update is displayed - fixed MAGETWO-53037: Product duplication allows to save non-unique values for product attributes
2 parents ee8bd11 + 8dd44d0 commit 08fbdf1

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
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>

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)