Skip to content

Commit 8c0e11b

Browse files
author
Joan He
committed
Merge remote-tracking branch 'trigger/MC-5517' into BugFixPR
2 parents c42e109 + c050f50 commit 8c0e11b

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
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/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>

0 commit comments

Comments
 (0)