Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigurablePriceResolver.php
Go to the documentation of this file.
1 <?php
8 
12 
14 {
18  protected $priceResolver;
19 
24  protected $priceCurrency;
25 
30  protected $configurable;
31 
35  private $lowestPriceOptionsProvider;
36 
43  public function __construct(
47  LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider = null
48  ) {
49  $this->priceResolver = $priceResolver;
50  $this->configurable = $configurable;
51  $this->priceCurrency = $priceCurrency;
52  $this->lowestPriceOptionsProvider = $lowestPriceOptionsProvider ?:
53  ObjectManager::getInstance()->get(LowestPriceOptionsProviderInterface::class);
54  }
55 
61  public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)
62  {
63  $price = null;
64 
65  foreach ($this->lowestPriceOptionsProvider->getProducts($product) as $subProduct) {
66  $productPrice = $this->priceResolver->resolvePrice($subProduct);
67  $price = isset($price) ? min($price, $productPrice) : $productPrice;
68  }
69 
70  return (float)$price;
71  }
72 }
$price
resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)
__construct(PriceResolverInterface $priceResolver, Configurable $configurable, PriceCurrencyInterface $priceCurrency, LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider=null)