Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
[EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
 - merged latest code from mainline branch
  • Loading branch information
magento-engcom-team authored Mar 28, 2019
2 parents 73c8d0a + 08fbdf1 commit 4f5aa1c
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 2 deletions.
22 changes: 22 additions & 0 deletions app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public function execute()
if ($redirectBack === 'duplicate') {
$product->unsetData('quantity_and_stock_status');
$newProduct = $this->productCopier->copy($product);
$this->checkUniqueAttributes($product);
$this->messageManager->addSuccessMessage(__('You duplicated the product.'));
}
} catch (\Magento\Framework\Exception\LocalizedException $e) {
Expand Down Expand Up @@ -343,4 +344,25 @@ private function persistMediaData(ProductInterface $product, array $data)

return $data;
}

/**
* Check unique attributes and add error to message manager
*
* @param \Magento\Catalog\Model\Product $product
*/
private function checkUniqueAttributes(\Magento\Catalog\Model\Product $product)
{
$uniqueLabels = [];
foreach ($product->getAttributes() as $attribute) {
if ($attribute->getIsUnique() && $attribute->getIsUserDefined()
&& $product->getData($attribute->getAttributeCode()) !== null
) {
$uniqueLabels[] = $attribute->getDefaultFrontendLabel();
}
}
if ($uniqueLabels) {
$uniqueLabels = implode('", "', $uniqueLabels);
$this->messageManager->addErrorMessage(__('The value of attribute(s) "%1" must be unique', $uniqueLabels));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<severity value="CRITICAL"/>
<testCaseId value="MC-10905"/>
<group value="mtf_migrated"/>
<skip>
<issueId value="MC-15474"/>
</skip>
</annotations>

<before>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<group value="catalog"/>
<group value="mtf_migrated"/>
<skip>
<issueId value="MAGETWO-62808"/>
<issueId value="MSI-2110"/>
</skip>
</annotations>
<before>
Expand Down Expand Up @@ -83,4 +83,120 @@
<argument name="optionName" value="$createConfigProductAttributeOption1.option[store_labels][1][label]$"/>
</actionGroup>
</test>
<test name="AdminCreateSimpleProductSwitchToConfigurableTest" extends="AdminCreateSimpleProductSwitchToVirtualTest">
<annotations>
<features value="Catalog"/>
<stories value="Product Type Switching"/>
<title value="Admin should be able to switch a new product from simple to configurable"/>
<description value="After selecting a simple product when adding Admin should be switch to configurable implicitly"/>
<severity value="CRITICAL"/>
<useCaseId value="MAGETWO-44165"/>
<testCaseId value="MAGETWO-29398"/>
<group value="catalog"/>
<group value="mtf_migrated"/>
<skip>
<issueId value="MSI-2110"/>
</skip>
</annotations>
<before>
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
<requiredEntity createDataKey="createConfigProductAttribute"/>
</createData>
</before>
<after>
<deleteData stepKey="deleteAttribute" createDataKey="createConfigProductAttribute"/>
</after>
<actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="openProductFillForm">
<argument name="productType" value="simple"/>
</actionGroup>
<!-- Create configurable product from simple product page-->
<comment userInput="Create configurable product" stepKey="commentCreateProduct"/>
<actionGroup ref="fillMainProductForm" stepKey="fillProductForm">
<argument name="product" value="_defaultProduct"/>
</actionGroup>
<comment before="createConfiguration" stepKey="beforeCreateConfiguration" userInput="Adding Configuration to Product"/>
<actionGroup ref="generateConfigurationsByAttributeCode" stepKey="createConfiguration" after="fillProductForm">
<argument name="attributeCode" value="$$createConfigProductAttribute.attribute_code$$"/>
</actionGroup>
<actionGroup ref="saveConfiguredProduct" stepKey="saveProductForm"/>
<see selector="{{AdminProductGridSection.productGridCell('2', 'Type')}}" userInput="Configurable Product" stepKey="seeProductTypeInGrid"/>
<!-- Verify product on store front -->
<comment userInput="Verify product on store front" stepKey="commentVerifyProductGrid"/>
<actionGroup ref="VerifyOptionInProductStorefront" stepKey="verifyConfigurableOption" after="AssertProductInStorefrontProductPage">
<argument name="attributeCode" value="$createConfigProductAttribute.default_frontend_label$"/>
<argument name="optionName" value="$createConfigProductAttributeOption1.option[store_labels][1][label]$"/>
</actionGroup>
</test>
<test name="AdminCreateDownloadableProductSwitchToConfigurableTest">
<annotations>
<features value="Catalog"/>
<stories value="Product Type Switching"/>
<title value="Admin should be able to switch a new product from downloadable to configurable"/>
<description value="After selecting a downloadable product when adding Admin should be switch to configurable implicitly"/>
<severity value="CRITICAL"/>
<useCaseId value="MAGETWO-44165"/>
<testCaseId value="MAGETWO-29398"/>
<group value="catalog"/>
<group value="mtf_migrated"/>
<skip>
<issueId value="MSI-2110"/>
</skip>
</annotations>
<before>
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/>
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
<requiredEntity createDataKey="createConfigProductAttribute"/>
</createData>
</before>
<after>
<actionGroup ref="GoToProductCatalogPage" stepKey="goToProductCatalogPage"/>
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteConfigurableProduct">
<argument name="product" value="_defaultProduct"/>
</actionGroup>
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetSearch"/>
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
<deleteData stepKey="deleteAttribute" createDataKey="createConfigProductAttribute"/>
<actionGroup ref="logout" stepKey="logout"/>
</after>
<!-- Create configurable product from downloadable product page-->
<comment userInput="Create configurable product" stepKey="commentCreateProduct"/>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
<!-- Open Dropdown and select downloadable product option -->
<comment stepKey="beforeOpenProductFillForm" userInput="Selecting Product from the Add Product Dropdown"/>
<actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="openProductFillForm">
<argument name="productType" value="downloadable"/>
</actionGroup>
<scrollTo selector="{{AdminProductDownloadableSection.sectionHeader}}" stepKey="scrollToDownloadableInfo" />
<uncheckOption selector="{{AdminProductDownloadableSection.isDownloadableProduct}}" stepKey="checkIsDownloadable"/>
<!-- Fill form for Downloadable Product Type -->
<comment stepKey="beforeFillProductForm" userInput="Filling Product Form"/>
<actionGroup ref="fillMainProductForm" stepKey="fillProductForm">
<argument name="product" value="_defaultProduct"/>
</actionGroup>
<actionGroup ref="SetProductUrlKey" stepKey="setProductUrl">
<argument name="product" value="_defaultProduct"/>
</actionGroup>
<comment before="createConfiguration" stepKey="beforeCreateConfiguration" userInput="Adding Configuration to Product"/>
<actionGroup ref="generateConfigurationsByAttributeCode" stepKey="createConfiguration">
<argument name="attributeCode" value="$$createConfigProductAttribute.attribute_code$$"/>
</actionGroup>
<actionGroup ref="saveConfiguredProduct" stepKey="saveProductForm"/>
<!-- Check that product was added with implicit type change -->
<comment stepKey="beforeVerify" userInput="Verify Product Type Assigned Correctly"/>
<actionGroup ref="GoToProductCatalogPage" stepKey="goToProductCatalogPage"/>
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetSearch"/>
<actionGroup ref="filterProductGridByName" stepKey="searchForProduct">
<argument name="product" value="_defaultProduct"/>
</actionGroup>
<see selector="{{AdminProductGridSection.productGridCell('2', 'Type')}}" userInput="Configurable Product" stepKey="seeProductTypeInGrid"/>
<actionGroup ref="AssertProductInStorefrontProductPage" stepKey="assertProductInStorefrontProductPage">
<argument name="product" value="_defaultProduct"/>
</actionGroup>
<actionGroup ref="VerifyOptionInProductStorefront" stepKey="verifyConfigurableOption">
<argument name="attributeCode" value="$createConfigProductAttribute.default_frontend_label$"/>
<argument name="optionName" value="$createConfigProductAttributeOption1.option[store_labels][1][label]$"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ public function assignCategory($parentCategoryName, $childCategoryName)
*/
public function expandAllCategories()
{
$this->getTemplateBlock()->waitLoader();
$this->_rootElement->find($this->expandAll)->click();
$this->getTemplateBlock()->waitLoader();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getSelectSortType()
public function getSortType()
{
$content = $this->_rootElement->find($this->sorter)->getText();
return explode("\n", $content);
return array_values(array_filter(array_map('trim', explode("\n", $content))));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForAssignedProducts" />
</variation>
<variation name="CreateCategoryEntityTestVariation5_Anchor_MostOfFields">
<data name="tag" xsi:type="string">test_type:acceptance_test</data>
<data name="description" xsi:type="string">Create anchor subcategory with all fields</data>
<data name="addCategory" xsi:type="string">addSubcategory</data>
<data name="category/data/parent_id/dataset" xsi:type="string">default_category</data>
Expand Down

0 comments on commit 4f5aa1c

Please sign in to comment.