Skip to content

ISSUE-23181: Including new entries for including the weight when creating simple products #31534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Catalog\Model\Locator\LocatorInterface;
use Magento\Catalog\Model\Product;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Directory\Helper\Data as DirectoryHelper;

/**
* Product variations matrix block
Expand Down Expand Up @@ -66,6 +67,11 @@ class Matrix extends \Magento\Backend\Block\Template
*/
protected $locator;

/**
* @var DirectoryHelper
*/
protected $directoryHelper;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configurableType
Expand All @@ -75,6 +81,7 @@ class Matrix extends \Magento\Backend\Block\Template
* @param \Magento\Catalog\Helper\Image $image
* @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency
* @param LocatorInterface $locator
* @param DirectoryHelper $directoryHelper
* @param array $data
*/
public function __construct(
Expand All @@ -86,6 +93,7 @@ public function __construct(
\Magento\Catalog\Helper\Image $image,
\Magento\Framework\Locale\CurrencyInterface $localeCurrency,
LocatorInterface $locator,
DirectoryHelper $directoryHelper,
array $data = []
) {
parent::__construct($context, $data);
Expand All @@ -96,6 +104,7 @@ public function __construct(
$this->localeCurrency = $localeCurrency;
$this->image = $image;
$this->locator = $locator;
$this->directoryHelper = $directoryHelper;
}

/**
Expand Down Expand Up @@ -443,4 +452,12 @@ private function prepareAttributes(

return [$attributes, $variationOptions];
}

/**
* @return string
*/
public function getWeightUnit()
{
return $this->directoryHelper->getWeightUnit();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="CreateConfigurableProductWithWeightActionGroup">
<annotations>
<description>Goes to the Admin Product grid page. Creates a Configurable Product with weight using the default Product Options.</description>
</annotations>
<arguments>
<argument name="product" defaultValue="_defaultProduct"/>
<argument name="category" defaultValue="_defaultCategory"/>
</arguments>

<!-- fill in basic configurable product values -->
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="amOnProductGridPage"/>
<waitForPageLoad time="30" stepKey="wait1"/>
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickOnAddProductToggle"/>
<click selector="{{AdminProductGridActionSection.addConfigurableProduct}}" stepKey="clickOnAddConfigurableProduct"/>
<fillField userInput="{{product.name}}" selector="{{AdminProductFormSection.productName}}" stepKey="fillName"/>
<fillField userInput="{{product.sku}}" selector="{{AdminProductFormSection.productSku}}" stepKey="fillSKU"/>
<fillField userInput="{{product.price}}" selector="{{AdminProductFormSection.productPrice}}" stepKey="fillPrice"/>
<fillField userInput="{{product.quantity}}" selector="{{AdminProductFormSection.productQuantity}}" stepKey="fillQuantity"/>
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[{{category.name}}]" stepKey="fillCategory"/>
<selectOption userInput="{{product.visibility}}" selector="{{AdminProductFormSection.visibility}}" stepKey="fillVisibility"/>
<click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="openSeoSection"/>
<fillField userInput="{{product.urlKey}}" selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="fillUrlKey"/>

<!-- create configurations for colors the product is available in -->
<click selector="{{AdminProductFormConfigurationsSection.createConfigurations}}" stepKey="clickOnCreateConfigurations"/>
<click selector="{{AdminCreateProductConfigurationsPanel.createNewAttribute}}" stepKey="clickOnNewAttribute"/>
<waitForPageLoad stepKey="waitForIFrame"/>
<switchToIFrame selector="{{AdminNewAttributePanel.newAttributeIFrame}}" stepKey="switchToNewAttributeIFrame"/>
<fillField selector="{{AdminNewAttributePanel.defaultLabel}}" userInput="{{colorProductAttribute.default_label}}" stepKey="fillDefaultLabel"/>
<click selector="{{AdminNewAttributePanel.saveAttribute}}" stepKey="clickOnNewAttributePanel"/>
<waitForPageLoad stepKey="waitForSaveAttribute"/>
<switchToIFrame stepKey="switchOutOfIFrame"/>
<waitForPageLoad stepKey="waitForFilters"/>
<click selector="{{AdminCreateProductConfigurationsPanel.filters}}" stepKey="clickOnFilters"/>
<fillField userInput="{{colorProductAttribute.default_label}}" selector="{{AdminCreateProductConfigurationsPanel.attributeCode}}" stepKey="fillFilterAttributeCodeField"/>
<click selector="{{AdminCreateProductConfigurationsPanel.applyFilters}}" stepKey="clickApplyFiltersButton"/>
<click selector="{{AdminCreateProductConfigurationsPanel.firstCheckbox}}" stepKey="clickOnFirstCheckbox"/>
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton1"/>
<waitForElementVisible selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="waitCreateNewValueAppears"/>
<click selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="clickOnCreateNewValue1"/>
<fillField userInput="{{colorProductAttribute1.name}}" selector="{{AdminCreateProductConfigurationsPanel.attributeName}}" stepKey="fillFieldForNewAttribute1"/>
<click selector="{{AdminCreateProductConfigurationsPanel.saveAttribute}}" stepKey="clickOnSaveNewAttribute1"/>
<click selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="clickOnCreateNewValue2"/>
<fillField userInput="{{colorProductAttribute2.name}}" selector="{{AdminCreateProductConfigurationsPanel.attributeName}}" stepKey="fillFieldForNewAttribute2"/>
<click selector="{{AdminCreateProductConfigurationsPanel.saveAttribute}}" stepKey="clickOnSaveNewAttribute2"/>
<click selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="clickOnCreateNewValue3"/>
<fillField userInput="{{colorProductAttribute3.name}}" selector="{{AdminCreateProductConfigurationsPanel.attributeName}}" stepKey="fillFieldForNewAttribute3"/>
<click selector="{{AdminCreateProductConfigurationsPanel.saveAttribute}}" stepKey="clickOnSaveNewAttribute3"/>
<click selector="{{AdminCreateProductConfigurationsPanel.selectAll}}" stepKey="clickOnSelectAll"/>
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton2"/>
<click selector="{{AdminCreateProductConfigurationsPanel.applyUniquePricesByAttributeToEachSku}}" stepKey="clickOnApplyUniquePricesByAttributeToEachSku"/>
<selectOption selector="{{AdminCreateProductConfigurationsPanel.selectAttribute}}" userInput="{{colorProductAttribute.default_label}}" stepKey="selectAttributes"/>
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute1}}" userInput="{{colorProductAttribute1.price}}" stepKey="fillAttributePrice1"/>
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute2}}" userInput="{{colorProductAttribute2.price}}" stepKey="fillAttributePrice2"/>
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute3}}" userInput="{{colorProductAttribute3.price}}" stepKey="fillAttributePrice3"/>
<click selector="{{AdminCreateProductConfigurationsPanel.applySingleQuantityToEachSkus}}" stepKey="clickOnApplySingleQuantityToEachSku"/>
<fillField selector="{{AdminCreateProductConfigurationsPanel.quantity}}" userInput="1" stepKey="enterAttributeQuantity"/>

<!-- Assigning weight to the associatted products -->
<click selector="{{AdminCreateProductConfigurationsPanel.applySingleWeightToEachSkus}}" stepKey="clickOnApplySingleWeightToEachSku"/>
<fillField selector="{{AdminCreateProductConfigurationsPanel.weight}}" userInput="1" stepKey="enterAttributeWeight"/>

<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton3"/>
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton4"/>
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton2"/>
<click selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" stepKey="clickOnConfirmInPopup"/>
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSaveProductMessage"/>
<seeInTitle userInput="{{product.name}}" stepKey="seeProductNameInTitle"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@
<element name="attributeCheckboxByName" type="input" selector="//*[contains(@data-attribute-option-title,'{{arg}}')]//input[@type='checkbox']" parameterized="true"/>
<element name="attributeColorCheckbox" type="select" selector="//div[contains(text(),'color') and @class='data-grid-cell-content']/../preceding-sibling::td/label/input"/>
<element name="attributeRowByAttributeCode" type="block" selector="//td[count(../../..//th[./*[.='Attribute Code']]/preceding-sibling::th) + 1][./*[.='{{attribute_code}}']]/../td//input[@data-action='select-row']" parameterized="true"/>
<element name="applySingleWeightToEachSkus" type="radio" selector=".admin__field-label[for='apply-single-weight-radio']" timeout="30" />
<element name="weight" type="input" selector="#apply-single-weight-input"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminConfigurableProductWithWeightCreateTest">
<annotations>
<features value="ConfigurableProduct"/>
<stories value="Create, Read, Update, Delete"/>
<title value="admin should be able to create a configurable product assigning weight to child products with attributes"/>
<description value="admin should be able to create a configurable product assigning weight to child products with attributes"/>
<severity value="AVERAGE"/>
<testCaseId value="MC-17466"/>
<group value="ConfigurableProduct"/>
</annotations>

<before>
<createData entity="ApiCategory" stepKey="createCategory"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/>
</before>

<after>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
</after>

<!-- Create a configurable product via the UI -->
<actionGroup ref="CreateConfigurableProductWithWeightActionGroup" stepKey="createProduct">
<argument name="product" value="_defaultProduct"/>
<argument name="category" value="$$createCategory$$"/>
</actionGroup>

<!-- assert color configurations on the admin create product page -->
<dontSee selector="{{AdminProductFormConfigurationsSection.variationLabel}}" stepKey="seeLabelNotVisible"/>
<seeNumberOfElements selector="{{AdminProductFormConfigurationsSection.currentVariationsRows}}" userInput="3" stepKey="seeNumberOfRows"/>
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsNameCells}}" userInput="{{colorProductAttribute1.name}}" stepKey="seeAttributeName1InField"/>
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsNameCells}}" userInput="{{colorProductAttribute2.name}}" stepKey="seeAttributeName2InField"/>
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsNameCells}}" userInput="{{colorProductAttribute3.name}}" stepKey="seeAttributeName3InField"/>
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsSkuCells}}" userInput="{{colorProductAttribute1.name}}" stepKey="seeAttributeSku1InField"/>
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsSkuCells}}" userInput="{{colorProductAttribute2.name}}" stepKey="seeAttributeSku2InField"/>
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsSkuCells}}" userInput="{{colorProductAttribute3.name}}" stepKey="seeAttributeSku3InField"/>
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsPriceCells}}" userInput="{{colorProductAttribute1.price}}" stepKey="seeUniquePrice1InField"/>
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsPriceCells}}" userInput="{{colorProductAttribute2.price}}" stepKey="seeUniquePrice2InField"/>
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsPriceCells}}" userInput="{{colorProductAttribute3.price}}" stepKey="seeUniquePrice3InField"/>
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsQuantityCells}}" userInput="{{colorProductAttribute.attribute_quantity}}" stepKey="seeQuantityInField"/>

<!-- assert storefront category list page -->
<amOnPage url="/" stepKey="amOnStorefront"/>
<waitForPageLoad stepKey="waitForPageLoad3"/>
<click userInput="$$createCategory.name$$" stepKey="clickOnCategoryName"/>
<waitForPageLoad stepKey="waitForPageLoad4"/>
<see userInput="{{_defaultProduct.name}}" stepKey="assertProductPresent"/>
<see userInput="{{colorProductAttribute1.price}}" stepKey="assertProductPricePresent"/>

<!-- assert storefront product details page -->
<click userInput="{{_defaultProduct.name}}" stepKey="clickOnProductName"/>
<waitForPageLoad stepKey="waitForPageLoad5"/>
<seeInTitle userInput="{{_defaultProduct.name}}" stepKey="assertProductNameTitle"/>
<see userInput="{{_defaultProduct.name}}" selector="{{StorefrontProductInfoMainSection.productName}}" stepKey="assertProductName"/>
<see userInput="{{colorProductAttribute1.price}}" selector="{{StorefrontProductInfoMainSection.productPrice}}" stepKey="assertProductPrice"/>
<see userInput="{{_defaultProduct.sku}}" selector="{{StorefrontProductInfoMainSection.productSku}}" stepKey="assertProductSku"/>
<see selector="{{StorefrontProductInfoMainSection.productAttributeTitle1}}" userInput="{{colorProductAttribute.default_label}}" stepKey="seeColorAttributeName1"/>
<see selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}" userInput="{{colorProductAttribute1.name}}" stepKey="seeInDropDown1"/>
<see selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}" userInput="{{colorProductAttribute2.name}}" stepKey="seeInDropDown2"/>
<see selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}" userInput="{{colorProductAttribute3.name}}" stepKey="seeInDropDown3"/>

<!-- Add configurable product to the cart with selected first option -->
<selectOption userInput="{{colorProductAttribute1.name}}" selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}" stepKey="selectOptionForAddingToCart"/>
<click selector="{{StorefrontProductInfoMainSection.AddToCart}}" stepKey="clickAddToCart"/>
<waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" stepKey="waitForSuccessMessage"/>

<!-- assert storefront product checkout page -->
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="clickOnMiniCartCheckoutButton"/>

<waitForElement selector="{{CheckoutShippingSection.shippingTab}}" time="30" stepKey="waitForShippingSectionLoaded"/>
</test>
</tests>
3 changes: 2 additions & 1 deletion app/code/Magento/ConfigurableProduct/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"magento/module-media-storage": "*",
"magento/module-quote": "*",
"magento/module-store": "*",
"magento/module-ui": "*"
"magento/module-ui": "*",
"magento/module-directory": "*"
},
"suggest": {
"magento/module-msrp": "*",
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/ConfigurableProduct/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<module name="Magento_Sales"/>
<module name="Magento_Quote"/>
<module name="Magento_Checkout"/>
<module name="Magento_Directory"/>
</sequence>
</module>
</config>
Loading