File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
app/code/Magento/Catalog/Pricing/Price Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ class MinimalTierPriceCalculator implements MinimalPriceCalculatorInterface
20
20
*/
21
21
private $ calculator ;
22
22
23
-
24
23
/**
25
24
* @param CalculatorInterface $calculator
26
25
*/
@@ -48,22 +47,16 @@ public function getValue(SaleableInterface $saleableItem)
48
47
*/
49
48
public function getAmount (SaleableInterface $ saleableItem )
50
49
{
51
- $ lowestTierPrice = null ;
50
+ $ minPrice = null ;
52
51
/** @var TierPrice $price */
53
52
$ tierPrice = $ saleableItem ->getPriceInfo ()->getPrice (TierPrice::PRICE_CODE );
54
53
$ tierPriceList = $ tierPrice ->getTierPriceList ();
55
- $ finalPrice = $ saleableItem ->getPriceInfo ()->getPrice (FinalPrice::PRICE_CODE )->getValue ();
56
54
57
- $ minPrice = $ finalPrice ;
58
- foreach ($ tierPriceList as $ tierPrice ) {
59
- /** @var AmountInterface $price */
60
- $ price = $ tierPrice ['price ' ];
61
- if ($ minPrice > $ price ->getValue ()) {
62
- $ minPrice = $ price ->getValue ();
63
- $ lowestTierPrice = $ price ;
64
- }
55
+ if (count ($ tierPriceList )) {
56
+ usort ($ tierPriceList , fn ($ tier1 , $ tier2 ) => $ tier1 ['price ' ]->getValue () <=> $ tier2 ['price ' ]->getValue ());
57
+ $ minPrice = array_shift ($ tierPriceList )['price ' ];
65
58
}
66
59
67
- return $ lowestTierPrice ;
60
+ return $ minPrice ;
68
61
}
69
62
}
You can’t perform that action at this time.
0 commit comments