Skip to content

Commit c942e9d

Browse files
committed
AC-7099:: 'As low as' label is still displayed for a Configurable Product price even if all options have the same price
1 parent 9597de7 commit c942e9d

File tree

5 files changed

+65
-42
lines changed

5 files changed

+65
-42
lines changed

app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableRegularPrice.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,17 @@ public function getValue()
9090
/**
9191
* Checks if all children simple products have the same price.
9292
*
93-
* @return bool Returns true if all products have the same price, false otherwise.
93+
* @return bool
9494
*/
95-
public function checkProductsHaveEqualPrices():bool
95+
public function isChildProductsOfEqualPrices():bool
9696
{
9797
$minPrice = $this->getMinRegularAmount()->getValue();
98-
$maxPrice= $this->getMaxRegularAmount()->getValue();
98+
$maxPrice = $this->getMaxRegularAmount()->getValue();
9999
foreach ($this->getUsedProducts() as $subProduct) {
100100
if ($subProduct->isAvailable() && !$subProduct->isDisabled()) {
101-
if ($specialPrice=$subProduct->getSpecialPrice()) {
102-
if ($specialPrice!=$minPrice) {
103-
return false;
104-
} else {
105-
return true;
106-
}
107-
} elseif ($subProduct->getFinalPrice()<$minPrice) {
101+
if ($specialPrice = $subProduct->getSpecialPrice()) {
102+
return !($specialPrice != $minPrice);
103+
} elseif ($subProduct->getFinalPrice() < $minPrice) {
108104
return false;
109105
}
110106
}

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

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="CreateConfigurableProductWithSamePriceActionGroup">
1212
<annotations>
13-
<description>Goes to the Admin Product grid page. Create a Configurable Product using the default Product Options with identical pricing.</description>
13+
<description>Goes to the Admin Product grid page.
14+
Create a Configurable Product using the default Product Options with identical pricing.</description>
1415
</annotations>
1516
<arguments>
1617
<argument name="product" defaultValue="_defaultProduct"/>
@@ -21,50 +22,75 @@
2122
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="amOnProductGridPage"/>
2223
<waitForPageLoad time="30" stepKey="wait1"/>
2324
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickOnAddProductToggle"/>
24-
<click selector="{{AdminProductGridActionSection.addConfigurableProduct}}" stepKey="clickOnAddConfigurableProduct"/>
25+
<click selector="{{AdminProductGridActionSection.addConfigurableProduct}}"
26+
stepKey="clickOnAddConfigurableProduct"/>
2527
<fillField userInput="{{product.name}}" selector="{{AdminProductFormSection.productName}}" stepKey="fillName"/>
2628
<fillField userInput="{{product.sku}}" selector="{{AdminProductFormSection.productSku}}" stepKey="fillSKU"/>
27-
<fillField userInput="{{product.price}}" selector="{{AdminProductFormSection.productPrice}}" stepKey="fillPrice"/>
28-
<fillField userInput="{{product.quantity}}" selector="{{AdminProductFormSection.productQuantity}}" stepKey="fillQuantity"/>
29-
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[{{category.name}}]" stepKey="fillCategory"/>
30-
<selectOption userInput="{{product.visibility}}" selector="{{AdminProductFormSection.visibility}}" stepKey="fillVisibility"/>
29+
<fillField userInput="{{product.price}}" selector="{{AdminProductFormSection.productPrice}}"
30+
stepKey="fillPrice"/>
31+
<fillField userInput="{{product.quantity}}" selector="{{AdminProductFormSection.productQuantity}}"
32+
stepKey="fillQuantity"/>
33+
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}"
34+
parameterArray="[{{category.name}}]" stepKey="fillCategory"/>
35+
<selectOption userInput="{{product.visibility}}" selector="{{AdminProductFormSection.visibility}}"
36+
stepKey="fillVisibility"/>
3137
<click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="openSeoSection"/>
32-
<fillField userInput="{{product.urlKey}}" selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="fillUrlKey"/>
38+
<fillField userInput="{{product.urlKey}}" selector="{{AdminProductSEOSection.urlKeyInput}}"
39+
stepKey="fillUrlKey"/>
3340

3441
<!-- create configurations for colors the product is available in -->
35-
<click selector="{{AdminProductFormConfigurationsSection.createConfigurations}}" stepKey="clickOnCreateConfigurations"/>
42+
<click selector="{{AdminProductFormConfigurationsSection.createConfigurations}}"
43+
stepKey="clickOnCreateConfigurations"/>
3644
<click selector="{{AdminCreateProductConfigurationsPanel.createNewAttribute}}" stepKey="clickOnNewAttribute"/>
3745
<waitForPageLoad stepKey="waitForIFrame"/>
3846
<switchToIFrame selector="{{AdminNewAttributePanel.newAttributeIFrame}}" stepKey="switchToNewAttributeIFrame"/>
39-
<fillField selector="{{AdminNewAttributePanel.defaultLabel}}" userInput="{{colorProductAttribute.default_label}}" stepKey="fillDefaultLabel"/>
47+
<fillField selector="{{AdminNewAttributePanel.defaultLabel}}"
48+
userInput="{{colorProductAttribute.default_label}}"
49+
stepKey="fillDefaultLabel"/>
4050
<click selector="{{AdminNewAttributePanel.saveAttribute}}" stepKey="clickOnNewAttributePanel"/>
4151
<waitForPageLoad stepKey="waitForSaveAttribute"/>
4252
<switchToIFrame stepKey="switchOutOfIFrame"/>
4353
<waitForPageLoad stepKey="waitForFilters"/>
4454
<click selector="{{AdminCreateProductConfigurationsPanel.filters}}" stepKey="clickOnFilters"/>
45-
<fillField userInput="{{colorProductAttribute.default_label}}" selector="{{AdminCreateProductConfigurationsPanel.attributeCode}}" stepKey="fillFilterAttributeCodeField"/>
55+
<fillField userInput="{{colorProductAttribute.default_label}}"
56+
selector="{{AdminCreateProductConfigurationsPanel.attributeCode}}"
57+
stepKey="fillFilterAttributeCodeField"/>
4658
<click selector="{{AdminCreateProductConfigurationsPanel.applyFilters}}" stepKey="clickApplyFiltersButton"/>
4759
<click selector="{{AdminCreateProductConfigurationsPanel.firstCheckbox}}" stepKey="clickOnFirstCheckbox"/>
4860
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton1"/>
49-
<waitForElementVisible selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="waitCreateNewValueAppears"/>
61+
<waitForElementVisible selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}"
62+
stepKey="waitCreateNewValueAppears"/>
5063
<click selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="clickOnCreateNewValue1"/>
51-
<fillField userInput="{{colorProductAttribute1.name}}" selector="{{AdminCreateProductConfigurationsPanel.attributeName}}" stepKey="fillFieldForNewAttribute1"/>
64+
<fillField userInput="{{colorProductAttribute1.name}}"
65+
selector="{{AdminCreateProductConfigurationsPanel.attributeName}}"
66+
stepKey="fillFieldForNewAttribute1"/>
5267
<click selector="{{AdminCreateProductConfigurationsPanel.saveAttribute}}" stepKey="clickOnSaveNewAttribute1"/>
5368
<click selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="clickOnCreateNewValue2"/>
54-
<fillField userInput="{{colorProductAttribute2.name}}" selector="{{AdminCreateProductConfigurationsPanel.attributeName}}" stepKey="fillFieldForNewAttribute2"/>
69+
<fillField userInput="{{colorProductAttribute2.name}}"
70+
selector="{{AdminCreateProductConfigurationsPanel.attributeName}}"
71+
stepKey="fillFieldForNewAttribute2"/>
5572
<click selector="{{AdminCreateProductConfigurationsPanel.saveAttribute}}" stepKey="clickOnSaveNewAttribute2"/>
5673
<click selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="clickOnCreateNewValue3"/>
57-
<fillField userInput="{{colorProductAttribute3.name}}" selector="{{AdminCreateProductConfigurationsPanel.attributeName}}" stepKey="fillFieldForNewAttribute3"/>
74+
<fillField userInput="{{colorProductAttribute3.name}}"
75+
selector="{{AdminCreateProductConfigurationsPanel.attributeName}}"
76+
stepKey="fillFieldForNewAttribute3"/>
5877
<click selector="{{AdminCreateProductConfigurationsPanel.saveAttribute}}" stepKey="clickOnSaveNewAttribute3"/>
5978
<click selector="{{AdminCreateProductConfigurationsPanel.selectAll}}" stepKey="clickOnSelectAll"/>
6079
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton2"/>
61-
<click selector="{{AdminCreateProductConfigurationsPanel.applyUniquePricesByAttributeToEachSku}}" stepKey="clickOnApplyUniquePricesByAttributeToEachSku"/>
62-
<selectOption selector="{{AdminCreateProductConfigurationsPanel.selectAttribute}}" userInput="{{colorProductAttribute.default_label}}" stepKey="selectAttributes"/>
63-
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute1}}" userInput="{{colorProductAttribute1.price}}" stepKey="fillAttributePrice1"/>
64-
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute2}}" userInput="{{colorProductAttribute1.price}}" stepKey="fillAttributePrice2"/>
65-
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute3}}" userInput="{{colorProductAttribute1.price}}" stepKey="fillAttributePrice3"/>
66-
<click selector="{{AdminCreateProductConfigurationsPanel.applySingleQuantityToEachSkus}}" stepKey="clickOnApplySingleQuantityToEachSku"/>
67-
<fillField selector="{{AdminCreateProductConfigurationsPanel.quantity}}" userInput="1" stepKey="enterAttributeQuantity"/>
80+
<click selector="{{AdminCreateProductConfigurationsPanel.applyUniquePricesByAttributeToEachSku}}"
81+
stepKey="clickOnApplyUniquePricesByAttributeToEachSku"/>
82+
<selectOption selector="{{AdminCreateProductConfigurationsPanel.selectAttribute}}"
83+
userInput="{{colorProductAttribute.default_label}}" stepKey="selectAttributes"/>
84+
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute1}}"
85+
userInput="{{colorProductAttribute1.price}}" stepKey="fillAttributePrice1"/>
86+
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute2}}"
87+
userInput="{{colorProductAttribute1.price}}" stepKey="fillAttributePrice2"/>
88+
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute3}}"
89+
userInput="{{colorProductAttribute1.price}}" stepKey="fillAttributePrice3"/>
90+
<click selector="{{AdminCreateProductConfigurationsPanel.applySingleQuantityToEachSkus}}"
91+
stepKey="clickOnApplySingleQuantityToEachSku"/>
92+
<fillField selector="{{AdminCreateProductConfigurationsPanel.quantity}}"
93+
userInput="1" stepKey="enterAttributeQuantity"/>
6894
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton3"/>
6995
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton4"/>
7096
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton2"/>

app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ConfigurableProductPriceLabelVisibilityWithoutAsLowAsTest.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,21 @@
66
*/
77
-->
88
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1010
<test name="ConfigurableProductPriceLabelVisibilityWithoutAsLowAsTest">
1111
<annotations>
1212
<features value="ConfigurableProduct"/>
1313
<stories value="View configurable product details in storefront"/>
14-
<title value="Guest customer should not see As low as label for Configurable Product with identical pricing"/>
15-
<description value="Guest customer should not see As low as label for Configurable Product with identical pricing"/>
14+
<title value="Customer should not see As low as label for Configurable Product with identical pricing"/>
15+
<description value="Customer should not see As low as label for Configurable Product with same pricing"/>
1616
<severity value="AVERAGE"/>
1717
<testCaseId value="AC-7099"/>
1818
<group value="ConfigurableProduct"/>
19-
<group value="cloud"/>
2019
</annotations>
2120

2221
<before>
2322
<createData entity="ApiCategory" stepKey="createCategory"/>
2423
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
25-
2624
<!-- Create a configurable product via the UI -->
2725
<actionGroup ref="CreateConfigurableProductWithSamePriceActionGroup" stepKey="createProduct">
2826
<argument name="product" value="_defaultProduct"/>
@@ -65,7 +63,8 @@
6563
<actionGroup ref="StorefrontAssertProductSkuOnProductPageActionGroup" stepKey="seeProductSku">
6664
<argument name="productSku" value="{{_defaultProduct.sku}}"/>
6765
</actionGroup>
68-
<dontSee userInput="As low as" selector="{{StorefrontProductInfoMainSection.productPriceLabel}}" stepKey="seeProductPriceLabel"/>
66+
<dontSee userInput="As low as" selector="{{StorefrontProductInfoMainSection.productPriceLabel}}"
67+
stepKey="seeProductPriceLabel"/>
6968
<actionGroup ref="AssertStorefrontProductStockStatusOnProductPageActionGroup" stepKey="seeProductStockStatus">
7069
<argument name="productStockStatus" value="In Stock"/>
7170
</actionGroup>
@@ -75,7 +74,8 @@
7574
<actionGroup ref="AssertStorefrontProductAttributeLabelVisibleActionGroup" stepKey="seeProductAttributeTitle">
7675
<argument name="productAttributeLabel" value="{{colorProductAttribute.default_label}}"/>
7776
</actionGroup>
78-
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeColorAttributeName1"/>
77+
<comment userInput="Comment is added to preserve the step key for backward compatibility"
78+
stepKey="seeColorAttributeName1"/>
7979
<actionGroup ref="AssertStorefrontProductAttributeOptionVisibleActionGroup" stepKey="seeInDropDown1">
8080
<argument name="productAttributeOption" value="{{colorProductAttribute1.name}}"/>
8181
</actionGroup>

app/code/Magento/ConfigurableProduct/view/base/templates/product/price/final_price.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $schema = ($block->getZone() == 'item_view') ? true : false;
1616
?>
1717
<span class="normal-price">
1818
<?= /* @noEscape */ $block->renderAmount($finalPriceModel->getAmount(), [
19-
'display_label' => $regularPriceModel->checkProductsHaveEqualPrices() ? '' : __('As low as'),
19+
'display_label' => $regularPriceModel->isChildProductsOfEqualPrices() ? '' : __('As low as'),
2020
'price_id' => $block->getPriceId('product-price-' . $idSuffix),
2121
'price_type' => 'finalPrice',
2222
'include_container' => true,

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableProductPriceTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,11 @@ private function processPriceView(string $sku): string
221221
public function assertPrice(string $sku, float $expectedPrice): void
222222
{
223223
$priceBlockHtml = $this->processPriceView($sku);
224-
$regexp = '/<span\s+class="price">\$%.2f<\/span>/';
224+
$regexp = '/<span class="price-label">As low as<\/span>.*';
225+
$regexp .= '<span.*data-price-amount="%s".*<span class="price">\$%.2f<\/span><\/span>/';
225226
$this->assertMatchesRegularExpression(
226-
sprintf($regexp, $expectedPrice),
227-
$priceBlockHtml
227+
sprintf($regexp, round($expectedPrice, 2), $expectedPrice),
228+
preg_replace('/[\n\r]/', '', $priceBlockHtml)
228229
);
229230
}
230231

0 commit comments

Comments
 (0)