Skip to content

Commit dcaaa19

Browse files
Merge remote-tracking branch 'remotes/github/MAGETWO-96842' into EPAM-PR-34
2 parents 320b292 + 987e07a commit dcaaa19

File tree

2 files changed

+116
-2
lines changed

2 files changed

+116
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminTierPriceNotAvailableForProductOptionsWithoutTierPriceTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<title value="Check that 'trie price' block not available for simple product from options without 'trie price'"/>
15+
<description value="Check that 'trie price' block not available for simple product from options without 'trie price'"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MAGETWO-97050"/>
18+
<useCaseId value="MAGETWO-96842"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
24+
<!--Create category-->
25+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
26+
27+
<!-- Create the configurable product based on the data in the /data folder -->
28+
<createData entity="ApiConfigurableProduct" stepKey="createConfigProduct">
29+
<requiredEntity createDataKey="createCategory"/>
30+
</createData>
31+
32+
<!-- Make the configurable product have two options, that are children of the default attribute set -->
33+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
34+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
35+
<requiredEntity createDataKey="createConfigProductAttribute"/>
36+
</createData>
37+
<createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2">
38+
<requiredEntity createDataKey="createConfigProductAttribute"/>
39+
</createData>
40+
<createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet">
41+
<requiredEntity createDataKey="createConfigProductAttribute"/>
42+
</createData>
43+
<getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeOption1">
44+
<requiredEntity createDataKey="createConfigProductAttribute"/>
45+
</getData>
46+
<getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeOption2">
47+
<requiredEntity createDataKey="createConfigProductAttribute"/>
48+
</getData>
49+
50+
<!-- Create the 2 children that will be a part of the configurable product -->
51+
<createData entity="ApiSimpleOne" stepKey="createConfigChildProduct1">
52+
<requiredEntity createDataKey="createConfigProductAttribute"/>
53+
<requiredEntity createDataKey="getConfigAttributeOption1"/>
54+
</createData>
55+
<createData entity="ApiSimpleTwo" stepKey="createConfigChildProduct2">
56+
<requiredEntity createDataKey="createConfigProductAttribute"/>
57+
<requiredEntity createDataKey="getConfigAttributeOption2"/>
58+
</createData>
59+
60+
<!-- Assign the two products to the configurable product -->
61+
<createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption">
62+
<requiredEntity createDataKey="createConfigProduct"/>
63+
<requiredEntity createDataKey="createConfigProductAttribute"/>
64+
<requiredEntity createDataKey="getConfigAttributeOption1"/>
65+
<requiredEntity createDataKey="getConfigAttributeOption2"/>
66+
</createData>
67+
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild1">
68+
<requiredEntity createDataKey="createConfigProduct"/>
69+
<requiredEntity createDataKey="createConfigChildProduct1"/>
70+
</createData>
71+
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild2">
72+
<requiredEntity createDataKey="createConfigProduct"/>
73+
<requiredEntity createDataKey="createConfigChildProduct2"/>
74+
</createData>
75+
</before>
76+
<after>
77+
<!--Delete created data-->
78+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
79+
<deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/>
80+
<deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/>
81+
<deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/>
82+
<deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/>
83+
84+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
85+
</after>
86+
87+
<!--Go to storefront product page an check price box css-->
88+
<amOnPage url="{{StorefrontProductPage.url($$createConfigProduct.custom_attributes[url_key]$$)}}" stepKey="navigateToSimpleProductPage"/>
89+
<waitForPageLoad stepKey="waitForStoreFrontLoad"/>
90+
<selectOption selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}" userInput="$$getConfigAttributeOption1.value$$" stepKey="selectOption"/>
91+
<grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productPrice}}" userInput="class" stepKey="grabGrabPriceClass"/>
92+
<assertNotContains actual="$grabGrabPriceClass" expected=".price-box .price-tier_price" expectedType="string" stepKey="assertNotEquals"/>
93+
</test>
94+
</tests>

app/code/Magento/ConfigurableProduct/Pricing/Render/TierPriceBox.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\ConfigurableProduct\Pricing\Render;
77

8+
use Magento\Catalog\Pricing\Price\TierPrice;
9+
810
/**
911
* Responsible for displaying tier price box on configurable product page.
1012
*
@@ -17,9 +19,27 @@ class TierPriceBox extends FinalPriceBox
1719
*/
1820
public function toHtml()
1921
{
20-
// Hide tier price block in case of MSRP.
21-
if (!$this->isMsrpPriceApplicable()) {
22+
// Hide tier price block in case of MSRP or in case when no options with tier price.
23+
if (!$this->isMsrpPriceApplicable() && $this->isTierPriceApplicable()) {
2224
return parent::toHtml();
2325
}
2426
}
27+
28+
/**
29+
* Check if at least one of simple products has tier price.
30+
*
31+
* @return bool
32+
*/
33+
private function isTierPriceApplicable()
34+
{
35+
$product = $this->getSaleableItem();
36+
foreach ($product->getTypeInstance()->getUsedProducts($product) as $simpleProduct) {
37+
if ($simpleProduct->isSalable() &&
38+
!empty($simpleProduct->getPriceInfo()->getPrice(TierPrice::PRICE_CODE)->getTierPriceList())
39+
) {
40+
return true;
41+
}
42+
}
43+
return false;
44+
}
2545
}

0 commit comments

Comments
 (0)