Skip to content

Commit b385e30

Browse files
committed
MC-33147: Most Tier Prices not Visible on Configurable variations
1 parent 6b6f428 commit b385e30

File tree

2 files changed

+87
-14
lines changed

2 files changed

+87
-14
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontConfigurableProductSwatchTierPriceTest">
11+
<annotations>
12+
<features value="Swatches"/>
13+
<stories value="Configurable product with swatch attribute"/>
14+
<title value="Swatch option should show the tier price on product page"/>
15+
<description value="Configurable product with swatch attribute should show the tier price on product page"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-34033"/>
18+
<useCaseId value="MC-33147"/>
19+
<group value="Swatches"/>
20+
</annotations>
21+
<before>
22+
<!-- Create configurable product -->
23+
<createData entity="ApiCategory" stepKey="createCategory"/>
24+
<createData entity="ApiConfigurableProduct" stepKey="createConfigurableProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
<!-- Login as Admin -->
28+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
29+
</before>
30+
<after>
31+
<!-- Delete configurable product -->
32+
<deleteData createDataKey="createConfigurableProduct" stepKey="deleteConfigurableProduct"/>
33+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
34+
<!-- Delete color attribute -->
35+
<actionGroup ref="DeleteProductAttributeActionGroup" stepKey="deleteColorAttribute">
36+
<argument name="ProductAttribute" value="ProductColorAttribute"/>
37+
</actionGroup>
38+
<!-- Logout -->
39+
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
40+
</after>
41+
42+
<!-- Create text swatch attribute with 3 options: Black, White and Blue -->
43+
<actionGroup ref="AddTextSwatchToProductActionGroup" stepKey="addColorAttribute">
44+
<argument name="attributeName" value="{{ProductColorAttribute.frontend_label}}"/>
45+
<argument name="attributeCode" value="{{ProductColorAttribute.attribute_code}}"/>
46+
<argument name="option1" value="Black"/>
47+
<argument name="option2" value="White"/>
48+
<argument name="option3" value="Blue"/>
49+
</actionGroup>
50+
<!-- Open configurable product edit page -->
51+
<amOnPage url="{{AdminProductEditPage.url($createConfigurableProduct.id$)}}" stepKey="goToConfigurableProduct"/>
52+
<!-- Generate configurations for configurable product -->
53+
<actionGroup ref="GenerateConfigurationsByAttributeCodeActionGroup" stepKey="createProductConfigurations">
54+
<argument name="attributeCode" value="{{ProductColorAttribute.attribute_code}}"/>
55+
</actionGroup>
56+
<actionGroup ref="SaveConfigurableProductAddToCurrentAttributeSetActionGroup" stepKey="saveConfigurableProduct"/>
57+
<!-- Set Tier Price to one of configuration product -->
58+
<actionGroup ref="FilterAndSelectProductActionGroup" stepKey="filterProduct">
59+
<argument name="productSku" value="$$createConfigurableProduct.sku$$-White"/>
60+
</actionGroup>
61+
<actionGroup ref="ProductSetAdvancedPricingActionGroup" stepKey="addTierPriceToSimpleProduct">
62+
<argument name="group" value="ALL GROUPS"/>
63+
<argument name="quantity" value="5"/>
64+
<argument name="price" value="Discount"/>
65+
<argument name="amount" value="50"/>
66+
</actionGroup>
67+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveSimpleProduct"/>
68+
<!-- Go to storefront product page -->
69+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openConfigurableProductPage">
70+
<argument name="productUrl" value="$createConfigurableProduct.custom_attributes[url_key]$"/>
71+
</actionGroup>
72+
<waitForPageLoad stepKey="waitForConfigurableProductPage"/>
73+
<!-- Select White configuration -->
74+
<actionGroup ref="StorefrontSelectSwatchOptionOnProductPageActionGroup" stepKey="selectWhiteOption">
75+
<argument name="optionName" value="White"/>
76+
</actionGroup>
77+
<!-- Assert tier price on selected configuration -->
78+
<actionGroup ref="AssertStorefrontProductDetailPageTierPriceActionGroup" stepKey="assertProductTierPriceText">
79+
<argument name="tierProductPriceDiscountQuantity" value="5"/>
80+
<argument name="productPriceWithAppliedTierPriceDiscount" value="61.50"/>
81+
<argument name="productSavedPricePercent" value="50"/>
82+
</actionGroup>
83+
</test>
84+
</tests>

app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,22 +1018,11 @@ define([
10181018
*/
10191019
_getNewPrices: function () {
10201020
var $widget = this,
1021-
optionPriceDiff = 0,
1022-
allowedProduct = this._getAllowedProductWithMinPrice(this._CalcProducts()),
1023-
optionPrices = this.options.jsonConfig.optionPrices,
1024-
basePrice = parseFloat(this.options.jsonConfig.prices.basePrice.amount),
1025-
optionFinalPrice,
1026-
newPrices;
1021+
newPrices = $widget.options.jsonConfig.prices,
1022+
allowedProduct = this._getAllowedProductWithMinPrice(this._CalcProducts());
10271023

10281024
if (!_.isEmpty(allowedProduct)) {
1029-
optionFinalPrice = parseFloat(optionPrices[allowedProduct].finalPrice.amount);
1030-
optionPriceDiff = optionFinalPrice - basePrice;
1031-
}
1032-
1033-
if (optionPriceDiff !== 0) {
1034-
newPrices = this.options.jsonConfig.optionPrices[allowedProduct];
1035-
} else {
1036-
newPrices = $widget.options.jsonConfig.prices;
1025+
newPrices = this.options.jsonConfig.optionPrices[allowedProduct];
10371026
}
10381027

10391028
return newPrices;

0 commit comments

Comments
 (0)