Skip to content

Commit 2001681

Browse files
committed
ACP2E-679: [Cloud] Dynamic SKU set to Yes even though it was changed to No via Mass Update [Blocker]
- fix - add test
1 parent 5807cd9 commit 2001681

File tree

5 files changed

+154
-0
lines changed

5 files changed

+154
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Bundle\Plugin\Framework\Data\Form\Element;
9+
10+
use Magento\Framework\Data\Form\Element\AbstractElement;
11+
use Magento\Framework\Data\Form\Element\Fieldset;
12+
13+
/**
14+
* Plugin that fixes mapping of value and label for bundle dynamic attributes
15+
*/
16+
class FieldsetPlugin
17+
{
18+
/**
19+
* @var string[]
20+
*/
21+
private $dynamicAttributeNames = ['sku_type', 'weight_type', 'price_type'];
22+
23+
/**
24+
* Normalise bundle dynamic attributes values
25+
*
26+
* Normalise attribute values for bundle dynamic attributes generated by form element
27+
* to make it consistent across the system (dynamic => 1, fixed => 0)
28+
*
29+
* @param Fieldset $subject
30+
* @param AbstractElement $result
31+
* @return AbstractElement
32+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
33+
*/
34+
public function afterAddField(Fieldset $subject, AbstractElement $result)
35+
{
36+
if (!in_array($result->getAttributeCode(), $this->dynamicAttributeNames)) {
37+
return $result;
38+
}
39+
40+
$new = [];
41+
foreach ($result->getValues() as $option) {
42+
$option['value'] = (int)!$option['value'];
43+
$new[] = $option;
44+
}
45+
46+
$result->setValues($new);
47+
return $result;
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminAssertBundleDynamicAttributesOnProductEditPageActionGroup">
12+
<annotations>
13+
<description>Verifies bundle dynamic attributes on the Product Edit page in admin.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="dynamicSku" defaultValue="true" type="string"/>
17+
<argument name="dynamicPrice" defaultValue="true" type="string"/>
18+
<argument name="dynamicWeight" defaultValue="true" type="string"/>
19+
</arguments>
20+
<executeJS function="return document.querySelector(&quot;{{AdminProductFormBundleSection.dynamicSkuInput}}&quot;).checked.toString()" stepKey="dynamicSkuCheckedValue"/>
21+
<assertEquals stepKey="assertDynamicSku">
22+
<actualResult type="variable">dynamicSkuCheckedValue</actualResult>
23+
<expectedResult type="string">{{dynamicSku}}</expectedResult>
24+
</assertEquals>
25+
<executeJS function="return document.querySelector(&quot;{{AdminProductFormBundleSection.dynamicPriceInput}}&quot;).checked.toString()" stepKey="dynamicPriceCheckedValue"/>
26+
<assertEquals stepKey="assertDynamicPrice">
27+
<actualResult type="variable">dynamicPriceCheckedValue</actualResult>
28+
<expectedResult type="string">{{dynamicPrice}}</expectedResult>
29+
</assertEquals>
30+
<executeJS function="return document.querySelector(&quot;{{AdminProductFormBundleSection.dynamicWeightInput}}&quot;).checked.toString()" stepKey="dynamicWeightCheckedValue"/>
31+
<assertEquals stepKey="assertDynamicWeight">
32+
<actualResult type="variable">dynamicWeightCheckedValue</actualResult>
33+
<expectedResult type="string">{{dynamicWeight}}</expectedResult>
34+
</assertEquals>
35+
</actionGroup>
36+
</actionGroups>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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="AdminBundleDynamicAttributesAfterMassUpdateTest">
12+
<annotations>
13+
<features value="Bundle"/>
14+
<stories value="Create/Edit bundle product in Admin"/>
15+
<title value="Verify dynamic attributes of bundle product after mass update"/>
16+
<description value="Verifies that dynamic attributes of bundle product are correctly updated using mass update"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="AC-2884"/>
19+
<group value="Bundle"/>
20+
</annotations>
21+
<before>
22+
<createData entity="ApiFixedBundleProduct" stepKey="createBundleProduct"/>
23+
</before>
24+
<after>
25+
<deleteData createDataKey="createBundleProduct" stepKey="deleteFixedBundleProduct"/>
26+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
27+
</after>
28+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
29+
30+
<actionGroup ref="AdminOpenCatalogProductPageActionGroup" stepKey="goToCatalogProductPage"/>
31+
<actionGroup ref="FilterProductGridByNameActionGroup" stepKey="filterBundleProductByName">
32+
<argument name="product" value="ApiFixedBundleProduct"/>
33+
</actionGroup>
34+
35+
<checkOption selector="{{AdminProductGridSection.productGridCheckboxOnRow('1')}}" stepKey="selectFirstProductFromGrid"/>
36+
<actionGroup ref="AdminClickMassUpdateProductAttributesActionGroup" stepKey="goToUpdateProductAttributesPage"/>
37+
38+
<checkOption selector="{{AdminEditProductAttributesSection.ChangeAttributeDynamicPriceToggle}}" stepKey="toggleToChangeDynamicPrice"/>
39+
<selectOption selector="{{AdminEditProductAttributesSection.AttributeDynamicPrice}}" userInput="No" stepKey="disableDynamicPrice"/>
40+
<checkOption selector="{{AdminEditProductAttributesSection.ChangeAttributeDynamicSKUToggle}}" stepKey="toggleToChangeDynamicSKU"/>
41+
<checkOption selector="{{AdminEditProductAttributesSection.ChangeAttributeDynamicWeightToggle}}" stepKey="toggleToChangeDynamicWeight"/>
42+
<selectOption selector="{{AdminEditProductAttributesSection.AttributeDynamicSKU}}" userInput="No" stepKey="disableDynamicSKU"/>
43+
<selectOption selector="{{AdminEditProductAttributesSection.AttributeDynamicWeight}}" userInput="No" stepKey="disableDynamicWeight"/>
44+
<actionGroup ref="AdminSaveProductsMassAttributesUpdateActionGroup" stepKey="saveMassAttributeUpdate"/>
45+
46+
<actionGroup ref="CliConsumerStartActionGroup" stepKey="startMessageQueueConsumer">
47+
<argument name="consumerName" value="{{AdminProductAttributeUpdateConsumerData.consumerName}}"/>
48+
<argument name="maxMessages" value="{{AdminProductAttributeUpdateConsumerData.messageLimit}}"/>
49+
</actionGroup>
50+
<magentoCLI command="cron:run" stepKey="runCron"/>
51+
52+
<actionGroup ref="OpenProductForEditByClickingRowXColumnYInProductGridActionGroup" stepKey="openProductForEdit"/>
53+
54+
<actionGroup ref="AdminAssertBundleDynamicAttributesOnProductEditPageActionGroup" stepKey="assertBundleProductDynamicAttributesOnEditPage">
55+
<argument name="dynamicSku" value="false"/>
56+
<argument name="dynamicPrice" value="false"/>
57+
<argument name="dynamicWeight" value="false"/>
58+
</actionGroup>
59+
</test>
60+
</tests>

app/code/Magento/Bundle/etc/adminhtml/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,7 @@
6666
</argument>
6767
</arguments>
6868
</type>
69+
<type name="Magento\Framework\Data\Form\Element\Fieldset">
70+
<plugin name="Bundle" type="Magento\Bundle\Plugin\Framework\Data\Form\Element\FieldsetPlugin"/>
71+
</type>
6972
</config>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,11 @@
2727
<element name="changeAttributeShortDescriptionToggle" type="checkbox" selector="#toggle_short_description"/>
2828
<element name="attributeInput" type="input" selector="#{{attributeCode}}" parameterized="true"/>
2929
<element name="toggleAttribute" type="checkbox" selector="#toggle_{{attributeCode}}" parameterized="true"/>
30+
<element name="AttributeDynamicPrice" type="select" selector="#price_type"/>
31+
<element name="AttributeDynamicSKU" type="select" selector="#sku_type"/>
32+
<element name="AttributeDynamicWeight" type="select" selector="#weight_type"/>
33+
<element name="ChangeAttributeDynamicPriceToggle" type="checkbox" selector="#toggle_price_type"/>
34+
<element name="ChangeAttributeDynamicSKUToggle" type="checkbox" selector="#toggle_sku_type"/>
35+
<element name="ChangeAttributeDynamicWeightToggle" type="checkbox" selector="#toggle_weight_type"/>
3036
</section>
3137
</sections>

0 commit comments

Comments
 (0)