Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MinimalTierPriceCalculator.php
Go to the documentation of this file.
1 <?php
8 
12 
17 {
21  private $calculator;
22 
26  public function __construct(CalculatorInterface $calculator)
27  {
28  $this->calculator = $calculator;
29  }
30 
35  public function getValue(SaleableInterface $saleableItem)
36  {
38  $price = $saleableItem->getPriceInfo()->getPrice(TierPrice::PRICE_CODE);
39  $tierPriceList = $price->getTierPriceList();
40 
41  $tierPrices = [];
42  foreach ($tierPriceList as $tierPrice) {
44  $price = $tierPrice['price'];
45  $tierPrices[] = $price->getValue();
46  }
47 
48  return $tierPrices ? min($tierPrices) : null;
49  }
50 
55  public function getAmount(SaleableInterface $saleableItem)
56  {
57  $value = $this->getValue($saleableItem);
58 
59  return $value === null
60  ? null
61  : $this->calculator->getAmount($value, $saleableItem);
62  }
63 }
$price
$value
Definition: gender.phtml:16