Skip to content

Commit 5ca6fc5

Browse files
author
Anna Bukatar
committed
ACP2E-313: Tiered Pricing display on PDP
1 parent d6756f9 commit 5ca6fc5

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

app/code/Magento/Catalog/Pricing/Price/TierPrice.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,14 @@ private function getConfigTaxDisplayType(): int
210210
protected function filterTierPrices(array $priceList)
211211
{
212212
$qtyCache = [];
213+
$minPrice = $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue();
213214
$allCustomersGroupId = $this->groupManagement->getAllCustomersGroup()->getId();
214215
foreach ($priceList as $priceKey => &$price) {
215-
if ($price['price'] >= $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue()) {
216+
if ($price['price'] >= $minPrice) {
216217
unset($priceList[$priceKey]);
217218
continue;
218219
}
219-
220+
$minPrice = $price['price'];
220221
if (isset($price['price_qty']) && $price['price_qty'] == 1) {
221222
unset($priceList[$priceKey]);
222223
continue;

app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ class TierPriceTest extends TestCase
8484
*/
8585
private $customerGroupRetriever;
8686

87+
/**
88+
* @var MockObject
89+
*/
90+
private $scopeConfigMock;
91+
8792
/**
8893
* Initialize base dependencies
8994
*/
@@ -108,6 +113,7 @@ protected function setUp(): void
108113
$this->groupManagement = $this->getMockForAbstractClass(GroupManagementInterface::class);
109114

110115
$this->priceCurrencyMock = $this->getMockForAbstractClass(PriceCurrencyInterface::class);
116+
$this->scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class);
111117

112118
$this->model = new TierPrice(
113119
$this->product,
@@ -116,7 +122,8 @@ protected function setUp(): void
116122
$this->priceCurrencyMock,
117123
$this->session,
118124
$this->groupManagement,
119-
$this->customerGroupRetriever
125+
$this->customerGroupRetriever,
126+
$this->scopeConfigMock
120127
);
121128
}
122129

@@ -242,7 +249,8 @@ public function testGetterStoredTierPrices()
242249
$this->priceCurrencyMock,
243250
$this->session,
244251
$this->groupManagement,
245-
$this->customerGroupRetriever
252+
$this->customerGroupRetriever,
253+
$this->scopeConfigMock
246254
);
247255
$group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
248256
$group->expects($this->once())->method('getId')->willReturn(GroupManagement::CUST_GROUP_ALL);
@@ -305,21 +313,21 @@ public function providerForGetterTierPriceList()
305313
'tierPrices' => [
306314
// will be ignored due to customer group
307315
[
308-
'price' => '1.3',
309-
'website_price' => '1.3',
316+
'price' => '21.3',
317+
'website_price' => '21.3',
310318
'price_qty' => '1.3',
311319
'cust_group' => $this->customerGroup + 1
312320
],
313321
[
314-
'price' => '25.4',
315-
'website_price' => '25.4',
322+
'price' => '20.4',
323+
'website_price' => '20.4',
316324
'price_qty' => '5.',
317325
'cust_group' => Group::CUST_GROUP_ALL
318326
],
319327
// cases to calculate save percent
320328
[
321-
'price' => '15.1',
322-
'website_price' => '15.1',
329+
'price' => '20.1',
330+
'website_price' => '20.1',
323331
'price_qty' => '5.',
324332
'cust_group' => Group::CUST_GROUP_ALL
325333
],
@@ -339,8 +347,8 @@ public function providerForGetterTierPriceList()
339347
'basePrice' => 20.,
340348
'expectedResult' => [
341349
[
342-
'price' => '7.55',
343-
'website_price' => '7.55',
350+
'price' => '10.05',
351+
'website_price' => '10.05',
344352
'price_qty' => '5.',
345353
'cust_group' => Group::CUST_GROUP_ALL,
346354
],
@@ -418,7 +426,8 @@ public function testGetQuantity($quantity, $expectedValue)
418426
$this->priceCurrencyMock,
419427
$this->session,
420428
$this->groupManagement,
421-
$this->customerGroupRetriever
429+
$this->customerGroupRetriever,
430+
$this->scopeConfigMock
422431
);
423432

424433
$this->assertEquals($expectedValue, $tierPrice->getQuantity());

0 commit comments

Comments
 (0)