Skip to content

Commit 52ac954

Browse files
committed
Merge remote-tracking branch 'l3/ACP2E-313' into PR_L3_05_04_2022
2 parents 83f3d01 + a7620f3 commit 52ac954

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
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,13 @@ 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-
220220
if (isset($price['price_qty']) && $price['price_qty'] == 1) {
221221
unset($priceList[$priceKey]);
222222
continue;
@@ -239,6 +239,7 @@ protected function filterTierPrices(array $priceList)
239239
} else {
240240
$qtyCache[$price['price_qty']] = $priceKey;
241241
}
242+
$minPrice = $price['price'];
242243
}
243244
return array_values($priceList);
244245
}

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductOutOfStockWithTierPriceTest.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,8 @@
8686
<expectedResult type="string">Buy {{tierPriceOnDefault.qty_0}} for ${{tierPriceOnDefault.price_0}} each and save 100%</expectedResult>
8787
<actualResult type="variable">firstTierPriceText</actualResult>
8888
</assertEquals>
89-
<grabTextFrom selector="{{StorefrontProductInfoMainSection.productTierPriceByForTextLabel('2', tierPriceOnDefault.qty_1)}}" stepKey="secondTierPriceText"/>
90-
<assertEquals stepKey="assertTierPriceTextOnProductPage2">
91-
<expectedResult type="string">Buy {{tierPriceOnDefault.qty_1}} for ${{tierPriceOnDefault.price_1}} each and save 100%</expectedResult>
92-
<actualResult type="variable">secondTierPriceText</actualResult>
93-
</assertEquals>
89+
<dontSeeElement selector="{{StorefrontProductInfoMainSection.productTierPriceByForTextLabel('2', tierPriceOnDefault.qty_1)}}" stepKey="secondTierPriceText"/>
90+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="assertTierPriceTextOnProductPage2"/>
9491

9592
<!-- Verify customer see product out of stock status on product page -->
9693
<grabTextFrom selector="{{StorefrontProductInfoMainSection.productStockStatus}}" stepKey="productStockAvailableStatus"/>

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Magento\Framework\Pricing\Price\PriceInterface;
2323
use Magento\Framework\Pricing\PriceCurrencyInterface;
2424
use Magento\Framework\Pricing\PriceInfo\Base;
25+
use Magento\Framework\App\Config\ScopeConfigInterface;
2526
use PHPUnit\Framework\MockObject\MockObject;
2627
use PHPUnit\Framework\TestCase;
2728

@@ -84,6 +85,11 @@ class TierPriceTest extends TestCase
8485
*/
8586
private $customerGroupRetriever;
8687

88+
/**
89+
* @var MockObject
90+
*/
91+
private $scopeConfigMock;
92+
8793
/**
8894
* Initialize base dependencies
8995
*/
@@ -108,6 +114,7 @@ protected function setUp(): void
108114
$this->groupManagement = $this->getMockForAbstractClass(GroupManagementInterface::class);
109115

110116
$this->priceCurrencyMock = $this->getMockForAbstractClass(PriceCurrencyInterface::class);
117+
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
111118

112119
$this->model = new TierPrice(
113120
$this->product,
@@ -116,7 +123,8 @@ protected function setUp(): void
116123
$this->priceCurrencyMock,
117124
$this->session,
118125
$this->groupManagement,
119-
$this->customerGroupRetriever
126+
$this->customerGroupRetriever,
127+
$this->scopeConfigMock
120128
);
121129
}
122130

@@ -242,7 +250,8 @@ public function testGetterStoredTierPrices()
242250
$this->priceCurrencyMock,
243251
$this->session,
244252
$this->groupManagement,
245-
$this->customerGroupRetriever
253+
$this->customerGroupRetriever,
254+
$this->scopeConfigMock
246255
);
247256
$group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
248257
$group->expects($this->once())->method('getId')->willReturn(GroupManagement::CUST_GROUP_ALL);
@@ -305,21 +314,21 @@ public function providerForGetterTierPriceList()
305314
'tierPrices' => [
306315
// will be ignored due to customer group
307316
[
308-
'price' => '1.3',
309-
'website_price' => '1.3',
317+
'price' => '21.3',
318+
'website_price' => '21.3',
310319
'price_qty' => '1.3',
311320
'cust_group' => $this->customerGroup + 1
312321
],
313322
[
314-
'price' => '25.4',
315-
'website_price' => '25.4',
323+
'price' => '20.4',
324+
'website_price' => '20.4',
316325
'price_qty' => '5.',
317326
'cust_group' => Group::CUST_GROUP_ALL
318327
],
319328
// cases to calculate save percent
320329
[
321-
'price' => '15.1',
322-
'website_price' => '15.1',
330+
'price' => '20.1',
331+
'website_price' => '20.1',
323332
'price_qty' => '5.',
324333
'cust_group' => Group::CUST_GROUP_ALL
325334
],
@@ -339,8 +348,8 @@ public function providerForGetterTierPriceList()
339348
'basePrice' => 20.,
340349
'expectedResult' => [
341350
[
342-
'price' => '7.55',
343-
'website_price' => '7.55',
351+
'price' => '10.05',
352+
'website_price' => '10.05',
344353
'price_qty' => '5.',
345354
'cust_group' => Group::CUST_GROUP_ALL,
346355
],
@@ -418,7 +427,8 @@ public function testGetQuantity($quantity, $expectedValue)
418427
$this->priceCurrencyMock,
419428
$this->session,
420429
$this->groupManagement,
421-
$this->customerGroupRetriever
430+
$this->customerGroupRetriever,
431+
$this->scopeConfigMock
422432
);
423433

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

0 commit comments

Comments
 (0)