Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FinalPrice.php
Go to the documentation of this file.
1 <?php
8 
11 
16 {
20  const PRICE_CODE = 'final_price';
21 
25  private $basePrice;
26 
30  protected $minimalPrice;
31 
35  protected $maximalPrice;
36 
42  public function getValue()
43  {
44  return max(0, $this->getBasePrice()->getValue());
45  }
46 
52  public function getMinimalPrice()
53  {
54  if (!$this->minimalPrice) {
55  $minimalPrice = $this->product->getMinimalPrice();
56  if ($minimalPrice === null) {
57  $minimalPrice = $this->getValue();
58  } else {
59  $minimalPrice = $this->priceCurrency->convertAndRound($minimalPrice);
60  }
61  $this->minimalPrice = $this->calculator->getAmount($minimalPrice, $this->product);
62  }
63  return $this->minimalPrice;
64  }
65 
71  public function getMaximalPrice()
72  {
73  if (!$this->maximalPrice) {
74  $maximalPrice = $this->product->getMaximalPrice();
75  if ($maximalPrice === null) {
76  $maximalPrice = $this->getValue();
77  } else {
78  $maximalPrice = $this->priceCurrency->convertAndRound($maximalPrice);
79  }
80  $this->maximalPrice = $this->calculator->getAmount($maximalPrice, $this->product);
81  }
82  return $this->maximalPrice;
83  }
84 
90  protected function getBasePrice()
91  {
92  if (!$this->basePrice) {
93  $this->basePrice = $this->priceInfo->getPrice(BasePrice::PRICE_CODE);
94  }
95  return $this->basePrice;
96  }
97 }