Skip to content

Commit d75f39d

Browse files
authored
Merge pull request #3546 from magento-borg/BugFixPR
[2.3-develop] Bug Fixes
2 parents 4ad08d2 + 8c0e11b commit d75f39d

File tree

16 files changed

+543
-45
lines changed

16 files changed

+543
-45
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Backend/TierPrice/SaveHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ private function getAdditionalFields(array $objectArray): array
135135
* Check whether price has percentage value.
136136
*
137137
* @param array $priceRow
138-
* @return int|null
138+
* @return float|null
139139
*/
140-
private function getPercentage(array $priceRow): ?int
140+
private function getPercentage(array $priceRow): ?float
141141
{
142142
return isset($priceRow['percentage_value']) && is_numeric($priceRow['percentage_value'])
143-
? (int)$priceRow['percentage_value']
143+
? (float)$priceRow['percentage_value']
144144
: null;
145145
}
146146

app/code/Magento/Catalog/Model/Product/Attribute/Backend/TierPrice/UpdateHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ private function getAdditionalFields(array $objectArray): array
138138
* Check whether price has percentage value.
139139
*
140140
* @param array $priceRow
141-
* @return int|null
141+
* @return float|null
142142
*/
143-
private function getPercentage(array $priceRow): ?int
143+
private function getPercentage(array $priceRow): ?float
144144
{
145145
return isset($priceRow['percentage_value']) && is_numeric($priceRow['percentage_value'])
146-
? (int)$priceRow['percentage_value']
146+
? (float)$priceRow['percentage_value']
147147
: null;
148148
}
149149

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@
192192
<click selector="{{AdminProductGridConfirmActionSection.ok}}" stepKey="confirmProductDelete"/>
193193
</actionGroup>
194194

195+
<actionGroup name="deleteProductByName" extends="deleteProductBySku">
196+
<arguments>
197+
<argument name="sku" type="string" defaultValue=""/>
198+
<argument name="name" type="string"/>
199+
</arguments>
200+
<remove keyForRemoval="fillProductSkuFilter"/>
201+
<fillField selector="{{AdminProductGridFilterSection.nameFilter}}" userInput="{{name}}" stepKey="fillProductSkuFilter" after="openProductFilters"/>
202+
<remove keyForRemoval="seeProductSkuInGrid"/>
203+
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="{{name}}" stepKey="seeProductNameInGrid" after="clickApplyFilters"/>
204+
</actionGroup>
205+
195206
<!--Open product for edit by clicking row X and column Y in product grid-->
196207
<actionGroup name="openProducForEditByClickingRowXColumnYInProductGrid">
197208
<arguments>

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,4 +480,8 @@
480480
<requiredEntity type="product_extension_attribute">EavStock1</requiredEntity>
481481
<requiredEntity type="custom_attribute">CustomAttributeProductAttribute</requiredEntity>
482482
</entity>
483+
<entity name="ProductWithLongNameSku" extends="ApiSimpleProduct">
484+
<data key="name" unique="suffix">Product With Long Name And Sku - But not too long</data>
485+
<data key="sku" unique="suffix">Product With Long Name And Sku - But not too long</data>
486+
</entity>
483487
</entities>

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,56 @@
269269
<actualResult type="variable">grabTextFromMiniCartSubtotalField2</actualResult>
270270
</assertEquals>
271271
</test>
272+
<test name="AdminApplyTierPriceToProductWithPercentageDiscountTest">
273+
<annotations>
274+
<features value="Catalog"/>
275+
<stories value="MC-5517 - System tries to save 0 in Advanced Pricing which is invalid for Discount field"/>
276+
<title value="You should be able to apply tier price to a product with float percent discount."/>
277+
<description value="You should be able to apply tier price to a product with float percent discount."/>
278+
<severity value="AVERAGE"/>
279+
<testCaseId value="MAGETWO-96881"/>
280+
<group value="product"/>
281+
</annotations>
282+
<before>
283+
<createData entity="_defaultCategory" stepKey="createCategory"/>
284+
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
285+
<requiredEntity createDataKey="createCategory"/>
286+
<field key="price">100</field>
287+
</createData>
288+
</before>
289+
<after>
290+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
291+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
292+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/>
293+
<waitForPageLoad time="30" stepKey="waitForProductIndexPageLoad"/>
294+
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetGridToDefaultKeywordSearch"/>
295+
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
296+
</after>
297+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
298+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
299+
<argument name="product" value="$$createSimpleProduct$$"/>
300+
</actionGroup>
301+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct1">
302+
<argument name="product" value="$$createSimpleProduct$$"/>
303+
</actionGroup>
304+
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
305+
<click selector="{{AdminProductFormSection.advancedPricingLink}}" stepKey="clickOnAdvancedPricingButton"/>
306+
<waitForElement selector="{{AdminProductFormAdvancedPricingSection.customerGroupPriceAddButton}}" stepKey="waitForCustomerGroupPriceAddButton"/>
307+
<click selector="{{AdminProductFormAdvancedPricingSection.customerGroupPriceAddButton}}" stepKey="addCustomerGroupAllGroupsQty1PriceDiscountAndpercent"/>
308+
<fillField selector="{{AdminProductFormAdvancedPricingSection.productTierPriceQtyInput('0')}}" userInput="1" stepKey="fillProductTierPriceQtyInput"/>
309+
<selectOption selector="{{AdminProductFormAdvancedPricingSection.productTierPriceValueTypeSelect('0')}}" userInput="Discount" stepKey="selectProductTierPriceValueType"/>
310+
<fillField selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageValuePriceInput('0')}}" userInput="0.1" stepKey="selectProductTierPricePriceInput"/>
311+
<click selector="{{AdminProductFormAdvancedPricingSection.doneButton}}" stepKey="clickDoneButton"/>
312+
<actionGroup ref="saveProductForm" stepKey="saveProduct1"/>
313+
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.sku$$)}}" stepKey="goProductPageOnStorefront"/>
314+
<waitForPageLoad time="30" stepKey="waitForPageLoad1"/>
315+
<seeElement selector="{{StorefrontCategoryProductSection.productPriceFinal('99.90')}}" stepKey="assertProductFinalPriceProductPage"/>
316+
<seeElement selector="{{StorefrontCategoryProductSection.productPriceLabel('Regular Price')}}" stepKey="assertRegularPriceProductPage"/>
317+
<seeElement selector="{{StorefrontCategoryProductSection.productPriceOld('100')}}" stepKey="assertRegularPriceAmountProductPage"/>
318+
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="navigateToCategoryPage"/>
319+
<waitForPageLoad time="30" stepKey="waitForPageLoad2"/>
320+
<seeElement selector="{{StorefrontCategoryProductSection.productPriceFinal('99.90')}}" stepKey="assertProductFinalPriceCategoryPage"/>
321+
<seeElement selector="{{StorefrontCategoryProductSection.productPriceLabel('Regular Price')}}" stepKey="assertRegularPriceLabelCategoryPage"/>
322+
<seeElement selector="{{StorefrontCategoryProductSection.productPriceOld('100')}}" stepKey="assertRegularPriceAmountCategoryPage"/>
323+
</test>
272324
</tests>

app/code/Magento/Config/Model/Config/Structure.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ protected function _getGroupFieldPathsByAttribute(array $fields, $parentPath, $a
337337
/**
338338
* Collects config paths and their structure paths from configuration files.
339339
* Returns the map of config paths and their structure paths.
340-
*
341340
* All paths are declared in module's system.xml.
342341
*
343342
* ```xml
@@ -394,7 +393,7 @@ private function getFieldsRecursively(array $elements = [])
394393

395394
foreach ($elements as $element) {
396395
if (isset($element['children'])) {
397-
$result = array_replace_recursive(
396+
$result = array_merge_recursive(
398397
$result,
399398
$this->getFieldsRecursively($element['children'])
400399
);

app/code/Magento/Config/Test/Unit/Model/Config/StructureTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ public function testGetFieldPaths()
418418
'field_2'
419419
],
420420
'field_3' => [
421+
'field_3',
421422
'field_3'
422423
],
423424
'field_3_1' => [

app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<seeInTitle userInput="{{product.name}}" stepKey="seeProductNameInTitle"/>
106106
</actionGroup>
107107

108-
<actionGroup name="createConfigurationsForAttribute">
108+
<actionGroup name="generateConfigurationsByAttributeCode">
109109
<arguments>
110110
<argument name="attributeCode" type="string" defaultValue="SomeString"/>
111111
</arguments>
@@ -121,6 +121,12 @@
121121
<fillField selector="{{AdminCreateProductConfigurationsPanel.quantity}}" userInput="99" stepKey="enterAttributeQuantity"/>
122122
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton3"/>
123123
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton4"/>
124+
</actionGroup>
125+
126+
<actionGroup name="createConfigurationsForAttribute" extends="generateConfigurationsByAttributeCode">
127+
<arguments>
128+
<argument name="attributeCode" type="string" defaultValue="SomeString"/>
129+
</arguments>
124130
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton2"/>
125131
<click selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" stepKey="clickOnConfirmInPopup"/>
126132
</actionGroup>

app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminProductFormConfigurationsSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<element name="removeProductBtn" type="button" selector="//a[text()='Remove Product']"/>
2323
<element name="disableProductBtn" type="button" selector="//a[text()='Disable Product']"/>
2424
<element name="enableProductBtn" type="button" selector="//a[text()='Enable Product']"/>
25+
<element name="variationsSkuInputByRow" selector="[data-index='configurable-matrix'] table > tbody > tr:nth-of-type({{row}}) input[name*='sku']" type="input" parameterized="true"/>
26+
<element name="variationsSkuInputErrorByRow" selector="[data-index='configurable-matrix'] table > tbody > tr:nth-of-type({{row}}) .admin__field-error" type="text" parameterized="true"/>
2527
</section>
2628
<section name="AdminConfigurableProductFormSection">
2729
<element name="productWeight" type="input" selector=".admin__control-text[name='product[weight]']"/>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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="AdminConfigurableProductLongSkuTest">
12+
<annotations>
13+
<features value="ConfigurableProduct"/>
14+
<stories value="Create configurable product"/>
15+
<title value="Admin is able to create an product with a long sku below that is below the character limit"/>
16+
<description value="Try to create a product with sku slightly less than char limit. Get client side SKU length error for child products. Correct SKUs and save product succeeds."/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-5685"/>
19+
<group value="ConfigurableProduct"/>
20+
</annotations>
21+
22+
<before>
23+
<!--Create product attribute with options-->
24+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
25+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
26+
<requiredEntity createDataKey="createConfigProductAttribute"/>
27+
</createData>
28+
<createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2">
29+
<requiredEntity createDataKey="createConfigProductAttribute"/>
30+
</createData>
31+
<createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet">
32+
<requiredEntity createDataKey="createConfigProductAttribute"/>
33+
</createData>
34+
<getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeOption1">
35+
<requiredEntity createDataKey="createConfigProductAttribute"/>
36+
</getData>
37+
<getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeOption2">
38+
<requiredEntity createDataKey="createConfigProductAttribute"/>
39+
</getData>
40+
<!--Create Category-->
41+
<createData entity="ApiCategory" stepKey="createCategory"/>
42+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
43+
</before>
44+
45+
<after>
46+
<!--Clean up products-->
47+
<actionGroup ref="deleteProductByName" stepKey="cleanUpProducts">
48+
<argument name="sku" value="{{ProductWithLongNameSku.sku}}"/>
49+
<argument name="name" value="{{ProductWithLongNameSku.name}}"/>
50+
</actionGroup>
51+
<!--Clean up attribute-->
52+
<deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/>
53+
<!--Clean up category-->
54+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
55+
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
56+
</after>
57+
58+
<!--Create a configurable product with long name and sku-->
59+
<amOnPage url="{{AdminProductCreatePage.url(AddToDefaultSet.attributeSetId, 'configurable')}}" stepKey="goToProductCreatePage"/>
60+
<waitForPageLoad stepKey="waitForProductCreatePage"/>
61+
<fillField selector="{{AdminProductFormSection.productName}}" userInput="{{ProductWithLongNameSku.name}}" stepKey="fillProductName"/>
62+
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{ProductWithLongNameSku.sku}}" stepKey="fillProductSku"/>
63+
<fillField selector="{{AdminProductFormSection.productPrice}}" userInput="{{ProductWithLongNameSku.price}}" stepKey="fillProductPrice"/>
64+
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[$$createCategory.name$$]" stepKey="selectCategory"/>
65+
<!--Setup configurations-->
66+
<actionGroup ref="generateConfigurationsByAttributeCode" stepKey="setupConfigurations">
67+
<argument name="attributeCode" value="$$createConfigProductAttribute.attribute_code$$"/>
68+
</actionGroup>
69+
70+
<!--See SKU length errors in Current Variations grid-->
71+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProductFail"/>
72+
<seeInCurrentUrl url="{{AdminProductCreatePage.url(AddToDefaultSet.attributeSetId, 'configurable')}}" stepKey="seeRemainOnCreateProductPage"/>
73+
<see selector="{{AdminProductFormConfigurationsSection.variationsSkuInputErrorByRow('1')}}" userInput="Please enter less or equal than 64 symbols." stepKey="seeSkuTooLongError1"/>
74+
<see selector="{{AdminProductFormConfigurationsSection.variationsSkuInputErrorByRow('2')}}" userInput="Please enter less or equal than 64 symbols." stepKey="seeSkuTooLongError2"/>
75+
<!--Fix SKU lengths-->
76+
<fillField selector="{{AdminProductFormConfigurationsSection.variationsSkuInputByRow('1')}}" userInput="LongSku-$$getConfigAttributeOption1.label$$" stepKey="fixConfigurationSku1"/>
77+
<fillField selector="{{AdminProductFormConfigurationsSection.variationsSkuInputByRow('2')}}" userInput="LongSku-$$getConfigAttributeOption2.label$$" stepKey="fixConfigurationSku2"/>
78+
<!--Save product successfully-->
79+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProductSuccess"/>
80+
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSaveProductMessage"/>
81+
82+
<!--Assert configurations on the product edit pag-->
83+
<seeNumberOfElements selector="{{AdminProductFormConfigurationsSection.currentVariationsRows}}" userInput="2" stepKey="seeNumberOfRows"/>
84+
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsNameCells}}" userInput="{{ProductWithLongNameSku.name}}-$$getConfigAttributeOption1.label$$" stepKey="seeChildProductName1"/>
85+
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsNameCells}}" userInput="{{ProductWithLongNameSku.name}}-$$getConfigAttributeOption2.label$$" stepKey="seeChildProductName2"/>
86+
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsSkuCells}}" userInput="LongSku-$$getConfigAttributeOption1.label$$" stepKey="seeChildProductSku1"/>
87+
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsSkuCells}}" userInput="LongSku-$$getConfigAttributeOption2.label$$" stepKey="seeChildProductSku2"/>
88+
<see selector="{{AdminProductFormConfigurationsSection.currentVariationsPriceCells}}" userInput="{{ProductWithLongNameSku.price}}" stepKey="seeConfigurationsPrice"/>
89+
90+
<!--Assert storefront category list page-->
91+
<amOnPage url="/" stepKey="amOnStorefront"/>
92+
<waitForPageLoad stepKey="waitForStorefrontLoad"/>
93+
<click userInput="$$createCategory.name$$" stepKey="clickOnCategoryName"/>
94+
<waitForPageLoad stepKey="waitForCategoryPageLoad"/>
95+
<see userInput="{{ProductWithLongNameSku.name}}" stepKey="assertProductPresent"/>
96+
<see userInput="{{ProductWithLongNameSku.price}}" stepKey="assertProductPricePresent"/>
97+
98+
<!--Assert storefront product details page-->
99+
<click selector="{{StorefrontCategoryProductSection.ProductTitleByName(ProductWithLongNameSku.name)}}" stepKey="clickOnProductName"/>
100+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
101+
<seeInTitle userInput="{{ProductWithLongNameSku.name}}" stepKey="assertProductNameTitle"/>
102+
<see userInput="{{ProductWithLongNameSku.name}}" selector="{{StorefrontProductInfoMainSection.productName}}" stepKey="assertProductName"/>
103+
<see userInput="{{ProductWithLongNameSku.sku}}" selector="{{StorefrontProductInfoMainSection.productSku}}" stepKey="assertProductSku"/>
104+
<see selector="{{StorefrontProductInfoMainSection.productAttributeTitle1}}" userInput="$$createConfigProductAttribute.default_frontend_label$$" stepKey="seeColorAttributeName1"/>
105+
<see selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}" userInput="$$getConfigAttributeOption1.label$$" stepKey="seeInDropDown1"/>
106+
<see selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}" userInput="$$getConfigAttributeOption2.label$$" stepKey="seeInDropDown2"/>
107+
</test>
108+
</tests>

0 commit comments

Comments
 (0)