Skip to content

Commit

Permalink
ENGCOM-6914: #26583 Tier pricing save percent showing logic updated i…
Browse files Browse the repository at this point in the history
…n product detail page #26584
  • Loading branch information
slavvka committed Feb 19, 2020
2 parents 0c2fe15 + a45bbb8 commit 63b4c28
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontProductDetailPageFinalPriceActionGroup">
<arguments>
<argument name="finalProductPrice" type="string"/>
</arguments>
<grabTextFrom selector="{{StorefrontProductInfoMainSection.price}}" stepKey="productPriceText"/>
<assertEquals stepKey="assertProductPriceOnProductPage">
<expectedResult type="string">${{finalProductPrice}}</expectedResult>
<actualResult type="variable">productPriceText</actualResult>
</assertEquals>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontProductDetailPageNameActionGroup">
<arguments>
<argument name="productName" type="string"/>
</arguments>
<grabTextFrom selector="{{StorefrontProductInfoMainSection.productName}}" stepKey="productNameText"/>
<assertEquals stepKey="assertProductNameOnProductPage">
<expectedResult type="string">{{productName}}</expectedResult>
<actualResult type="variable">productNameText</actualResult>
</assertEquals>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontProductDetailPageTierPriceActionGroup">
<arguments>
<argument name="tierProductPriceDiscountQuantity" type="string"/>
<argument name="productPriceWithAppliedTierPriceDiscount" type="string"/>
<argument name="productSavedPricePercent" type="string"/>
</arguments>
<grabTextFrom selector="{{StorefrontProductInfoMainSection.tierPriceText}}" stepKey="tierPriceText"/>
<assertEquals stepKey="assertTierPriceTextOnProductPage">
<expectedResult type="string">Buy {{tierProductPriceDiscountQuantity}} for ${{productPriceWithAppliedTierPriceDiscount}} each and save {{productSavedPricePercent}}%</expectedResult>
<actualResult type="variable">tierPriceText</actualResult>
</assertEquals>
</actionGroup>
</actionGroups>
10 changes: 9 additions & 1 deletion app/code/Magento/Catalog/Test/Mftf/Data/TierPriceData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@
<data key="quantity">30</data>
<var key="sku" entityType="product" entityKey="sku" />
</entity>
</entities>
<entity name="tierProductPriceDiscount" type="catalogTierPrice">
<data key="price">36.00</data>
<data key="price_type">discount</data>
<data key="website_id">0</data>
<data key="customer_group">ALL GROUPS</data>
<data key="quantity">3</data>
<var key="sku" entityType="product" entityKey="sku" />
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StoreFrontSimpleProductWithSpecialAndTierDiscountPriceTest">
<annotations>
<features value="Catalog"/>
<title value="Apply discount tier price and custom price values for simple product"/>
<description value="Apply discount tier price and custom price values for simple product"/>
<severity value="MAJOR"/>
<group value="Catalog"/>
</annotations>
<before>
<createData entity="_defaultCategory" stepKey="createCategory"/>

<createData entity="ApiSimpleProduct" stepKey="createProduct">
<requiredEntity createDataKey="createCategory"/>
<field key="price">100.00</field>
</createData>

<createData entity="tierProductPriceDiscount" stepKey="addTierPrice">
<requiredEntity createDataKey="createProduct"/>
</createData>
</before>
<after>
<deleteData createDataKey="createProduct" stepKey="deleteSimpleProduct"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
</after>

<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>

<actionGroup ref="GoToProductPageViaIDActionGroup" stepKey="openAdminProductEditPage">
<argument name="productId" value="$createProduct.id$"/>
</actionGroup>

<actionGroup ref="AddSpecialPriceToProductActionGroup" stepKey="addSpecialPriceToProduct">
<argument name="price" value="65.00"/>
</actionGroup>

<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductForm"/>

<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductPage">
<argument name="productUrl" value="$createProduct.custom_attributes[url_key]$"/>
</actionGroup>

<actionGroup ref="AssertStorefrontProductDetailPageNameActionGroup" stepKey="assertProductNameText">
<argument name="productName" value="$createProduct.name$"/>
</actionGroup>

<actionGroup ref="AssertStorefrontProductDetailPageTierPriceActionGroup" stepKey="assertProductTierPriceText">
<argument name="tierProductPriceDiscountQuantity" value="{{tierProductPriceDiscount.quantity}}"/>
<argument name="productPriceWithAppliedTierPriceDiscount" value="64.00"/>
<argument name="productSavedPricePercent" value="2"/>
</actionGroup>

<actionGroup ref="AssertStorefrontProductDetailPageFinalPriceActionGroup" stepKey="assertProductFinalPriceText">
<argument name="finalProductPrice" value="65.00"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ $tierPrices = $tierPriceModel->getTierPriceList();
$msrpShowOnGesture = $block->getPriceType('msrp_price')->isShowPriceOnGesture();
$product = $block->getSaleableItem();
?>
<?php if (count($tierPrices)) : ?>
<?php if (count($tierPrices)): ?>
<ul class="<?= $block->escapeHtmlAttr(($block->hasListClass() ? $block->getListClass() : 'prices-tier items')) ?>">
<?php foreach ($tierPrices as $index => $price) : ?>
<?php foreach ($tierPrices as $index => $price): ?>
<li class="item">
<?php
$productId = $product->getId();
$isSaleable = $product->isSaleable();
$popupId = 'msrp-popup-' . $productId . $block->getRandomString(20);
if ($msrpShowOnGesture && $price['price']->getValue() < $product->getMsrp()) :
if ($msrpShowOnGesture && $price['price']->getValue() < $product->getMsrp()):
$addToCartUrl = '';
if ($isSaleable) {
$addToCartUrl = $this->helper(\Magento\Checkout\Helper\Cart::class)
Expand Down Expand Up @@ -60,7 +60,7 @@ $product = $block->getSaleableItem();
id="<?= $block->escapeHtmlAttr($popupId) ?>"
data-tier-price="<?= $block->escapeHtml($block->jsonEncode($tierPriceData)) ?>">
<?= $block->escapeHtml(__('Click for price')) ?></a>
<?php else :
<?php else:
$priceAmountBlock = $block->renderAmount(
$price['price'],
[
Expand All @@ -73,19 +73,20 @@ $product = $block->getSaleableItem();
?>
<?= /* @noEscape */ ($block->getShowDetailedPrice() !== false)
? __(
'Buy %1 for %2 each and <strong class="benefit">save<span class="percent tier-%3">&nbsp;%4</span>%</strong>',
'Buy %1 for %2 each and '.
'<strong class="benefit">save<span class="percent tier-%3">&nbsp;%4</span>%</strong>',
$price['price_qty'],
$priceAmountBlock,
$index,
$block->formatPercent($price['percentage_value'] ?? $tierPriceModel->getSavePercent($price['price']))
$block->formatPercent($tierPriceModel->getSavePercent($price['price']))
)
: __('Buy %1 for %2 each', $price['price_qty'], $priceAmountBlock);
?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php if ($msrpShowOnGesture) :?>
<?php if ($msrpShowOnGesture):?>
<script type="text/x-magento-init">
{
".product-info-main": {
Expand Down

0 comments on commit 63b4c28

Please sign in to comment.