BasePrice.php 968 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Catalog\Pricing\Price;
  7. use Magento\Framework\Pricing\Price\AbstractPrice;
  8. use Magento\Framework\Pricing\Price\BasePriceProviderInterface;
  9. /**
  10. * Class BasePrice
  11. */
  12. class BasePrice extends AbstractPrice
  13. {
  14. /**
  15. * Price type identifier string
  16. */
  17. const PRICE_CODE = 'base_price';
  18. /**
  19. * Get Base Price Value
  20. *
  21. * @return float|bool
  22. */
  23. public function getValue()
  24. {
  25. if ($this->value === null) {
  26. $this->value = false;
  27. foreach ($this->priceInfo->getPrices() as $price) {
  28. if ($price instanceof BasePriceProviderInterface && $price->getValue() !== false) {
  29. $this->value = min($price->getValue(), $this->value !== false ? $this->value: $price->getValue());
  30. }
  31. }
  32. }
  33. return $this->value;
  34. }
  35. }