Skip to content

Commit a45bbb8

Browse files
ENGCOM-6914: #26583 Tier pricing save percent showing logic updated in product detail page #26584
- Merge Pull Request #26584 from srsathish92/magento2:bug/26583-pdp-tier-price-save-percent - Merged commits: 1. 9c11369 2. 00317ef 3. ecc4ef5 4. 24b3fba 5. 62f8c6c 6. 0110496 7. 4680f70
2 parents a25c107 + 4680f70 commit a45bbb8

File tree

6 files changed

+144
-8
lines changed

6 files changed

+144
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontProductDetailPageFinalPriceActionGroup">
11+
<arguments>
12+
<argument name="finalProductPrice" type="string"/>
13+
</arguments>
14+
<grabTextFrom selector="{{StorefrontProductInfoMainSection.price}}" stepKey="productPriceText"/>
15+
<assertEquals stepKey="assertProductPriceOnProductPage">
16+
<expectedResult type="string">${{finalProductPrice}}</expectedResult>
17+
<actualResult type="variable">productPriceText</actualResult>
18+
</assertEquals>
19+
</actionGroup>
20+
</actionGroups>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontProductDetailPageNameActionGroup">
11+
<arguments>
12+
<argument name="productName" type="string"/>
13+
</arguments>
14+
<grabTextFrom selector="{{StorefrontProductInfoMainSection.productName}}" stepKey="productNameText"/>
15+
<assertEquals stepKey="assertProductNameOnProductPage">
16+
<expectedResult type="string">{{productName}}</expectedResult>
17+
<actualResult type="variable">productNameText</actualResult>
18+
</assertEquals>
19+
</actionGroup>
20+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontProductDetailPageTierPriceActionGroup">
11+
<arguments>
12+
<argument name="tierProductPriceDiscountQuantity" type="string"/>
13+
<argument name="productPriceWithAppliedTierPriceDiscount" type="string"/>
14+
<argument name="productSavedPricePercent" type="string"/>
15+
</arguments>
16+
<grabTextFrom selector="{{StorefrontProductInfoMainSection.tierPriceText}}" stepKey="tierPriceText"/>
17+
<assertEquals stepKey="assertTierPriceTextOnProductPage">
18+
<expectedResult type="string">Buy {{tierProductPriceDiscountQuantity}} for ${{productPriceWithAppliedTierPriceDiscount}} each and save {{productSavedPricePercent}}%</expectedResult>
19+
<actualResult type="variable">tierPriceText</actualResult>
20+
</assertEquals>
21+
</actionGroup>
22+
</actionGroups>

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,12 @@
6464
<data key="quantity">30</data>
6565
<var key="sku" entityType="product" entityKey="sku" />
6666
</entity>
67-
</entities>
67+
<entity name="tierProductPriceDiscount" type="catalogTierPrice">
68+
<data key="price">36.00</data>
69+
<data key="price_type">discount</data>
70+
<data key="website_id">0</data>
71+
<data key="customer_group">ALL GROUPS</data>
72+
<data key="quantity">3</data>
73+
<var key="sku" entityType="product" entityKey="sku" />
74+
</entity>
75+
</entities>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StoreFrontSimpleProductWithSpecialAndTierDiscountPriceTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<title value="Apply discount tier price and custom price values for simple product"/>
14+
<description value="Apply discount tier price and custom price values for simple product"/>
15+
<severity value="MAJOR"/>
16+
<group value="Catalog"/>
17+
</annotations>
18+
<before>
19+
<createData entity="_defaultCategory" stepKey="createCategory"/>
20+
21+
<createData entity="ApiSimpleProduct" stepKey="createProduct">
22+
<requiredEntity createDataKey="createCategory"/>
23+
<field key="price">100.00</field>
24+
</createData>
25+
26+
<createData entity="tierProductPriceDiscount" stepKey="addTierPrice">
27+
<requiredEntity createDataKey="createProduct"/>
28+
</createData>
29+
</before>
30+
<after>
31+
<deleteData createDataKey="createProduct" stepKey="deleteSimpleProduct"/>
32+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
33+
</after>
34+
35+
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
36+
37+
<actionGroup ref="GoToProductPageViaIDActionGroup" stepKey="openAdminProductEditPage">
38+
<argument name="productId" value="$createProduct.id$"/>
39+
</actionGroup>
40+
41+
<actionGroup ref="AddSpecialPriceToProductActionGroup" stepKey="addSpecialPriceToProduct">
42+
<argument name="price" value="65.00"/>
43+
</actionGroup>
44+
45+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductForm"/>
46+
47+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductPage">
48+
<argument name="productUrl" value="$createProduct.custom_attributes[url_key]$"/>
49+
</actionGroup>
50+
51+
<actionGroup ref="AssertStorefrontProductDetailPageNameActionGroup" stepKey="assertProductNameText">
52+
<argument name="productName" value="$createProduct.name$"/>
53+
</actionGroup>
54+
55+
<actionGroup ref="AssertStorefrontProductDetailPageTierPriceActionGroup" stepKey="assertProductTierPriceText">
56+
<argument name="tierProductPriceDiscountQuantity" value="{{tierProductPriceDiscount.quantity}}"/>
57+
<argument name="productPriceWithAppliedTierPriceDiscount" value="64.00"/>
58+
<argument name="productSavedPricePercent" value="2"/>
59+
</actionGroup>
60+
61+
<actionGroup ref="AssertStorefrontProductDetailPageFinalPriceActionGroup" stepKey="assertProductFinalPriceText">
62+
<argument name="finalProductPrice" value="65.00"/>
63+
</actionGroup>
64+
</test>
65+
</tests>

app/code/Magento/Catalog/view/base/templates/product/price/tier_prices.phtml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ $tierPrices = $tierPriceModel->getTierPriceList();
1717
$msrpShowOnGesture = $block->getPriceType('msrp_price')->isShowPriceOnGesture();
1818
$product = $block->getSaleableItem();
1919
?>
20-
<?php if (count($tierPrices)) : ?>
20+
<?php if (count($tierPrices)): ?>
2121
<ul class="<?= $block->escapeHtmlAttr(($block->hasListClass() ? $block->getListClass() : 'prices-tier items')) ?>">
22-
<?php foreach ($tierPrices as $index => $price) : ?>
22+
<?php foreach ($tierPrices as $index => $price): ?>
2323
<li class="item">
2424
<?php
2525
$productId = $product->getId();
2626
$isSaleable = $product->isSaleable();
2727
$popupId = 'msrp-popup-' . $productId . $block->getRandomString(20);
28-
if ($msrpShowOnGesture && $price['price']->getValue() < $product->getMsrp()) :
28+
if ($msrpShowOnGesture && $price['price']->getValue() < $product->getMsrp()):
2929
$addToCartUrl = '';
3030
if ($isSaleable) {
3131
$addToCartUrl = $this->helper(\Magento\Checkout\Helper\Cart::class)
@@ -60,7 +60,7 @@ $product = $block->getSaleableItem();
6060
id="<?= $block->escapeHtmlAttr($popupId) ?>"
6161
data-tier-price="<?= $block->escapeHtml($block->jsonEncode($tierPriceData)) ?>">
6262
<?= $block->escapeHtml(__('Click for price')) ?></a>
63-
<?php else :
63+
<?php else:
6464
$priceAmountBlock = $block->renderAmount(
6565
$price['price'],
6666
[
@@ -73,19 +73,20 @@ $product = $block->getSaleableItem();
7373
?>
7474
<?= /* @noEscape */ ($block->getShowDetailedPrice() !== false)
7575
? __(
76-
'Buy %1 for %2 each and <strong class="benefit">save<span class="percent tier-%3">&nbsp;%4</span>%</strong>',
76+
'Buy %1 for %2 each and '.
77+
'<strong class="benefit">save<span class="percent tier-%3">&nbsp;%4</span>%</strong>',
7778
$price['price_qty'],
7879
$priceAmountBlock,
7980
$index,
80-
$block->formatPercent($price['percentage_value'] ?? $tierPriceModel->getSavePercent($price['price']))
81+
$block->formatPercent($tierPriceModel->getSavePercent($price['price']))
8182
)
8283
: __('Buy %1 for %2 each', $price['price_qty'], $priceAmountBlock);
8384
?>
8485
<?php endif; ?>
8586
</li>
8687
<?php endforeach; ?>
8788
</ul>
88-
<?php if ($msrpShowOnGesture) :?>
89+
<?php if ($msrpShowOnGesture):?>
8990
<script type="text/x-magento-init">
9091
{
9192
".product-info-main": {

0 commit comments

Comments
 (0)