FinalPrice.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\ConfigurableProduct\Pricing\Price;
  7. class FinalPrice extends \Magento\Catalog\Pricing\Price\FinalPrice
  8. {
  9. /**
  10. * @var \Magento\ConfigurableProduct\Pricing\Price\PriceResolverInterface
  11. */
  12. protected $priceResolver;
  13. /**
  14. * @var array
  15. */
  16. protected $values = [];
  17. /**
  18. * @param \Magento\Framework\Pricing\SaleableInterface $saleableItem
  19. * @param float $quantity
  20. * @param \Magento\Framework\Pricing\Adjustment\CalculatorInterface $calculator
  21. * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
  22. * @param PriceResolverInterface $priceResolver
  23. */
  24. public function __construct(
  25. \Magento\Framework\Pricing\SaleableInterface $saleableItem,
  26. $quantity,
  27. \Magento\Framework\Pricing\Adjustment\CalculatorInterface $calculator,
  28. \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
  29. PriceResolverInterface $priceResolver
  30. ) {
  31. parent::__construct($saleableItem, $quantity, $calculator, $priceCurrency);
  32. $this->priceResolver = $priceResolver;
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function getValue()
  38. {
  39. if (!isset($this->values[$this->product->getId()])) {
  40. $this->values[$this->product->getId()] = $this->priceResolver->resolvePrice($this->product);
  41. }
  42. return $this->values[$this->product->getId()];
  43. }
  44. }