priceResolver = $priceResolver; $this->lowestPriceOptionsProvider = $lowestPriceOptionsProvider ?: ObjectManager::getInstance()->get(LowestPriceOptionsProviderInterface::class); } /** * {@inheritdoc} */ public function getValue() { if (!isset($this->values[$this->product->getId()])) { $this->values[$this->product->getId()] = $this->priceResolver->resolvePrice($this->product); } return $this->values[$this->product->getId()]; } /** * {@inheritdoc} */ public function getAmount() { return $this->getMinRegularAmount(); } /** * {@inheritdoc} */ public function getMaxRegularAmount() { if (null === $this->maxRegularAmount) { $this->maxRegularAmount = $this->doGetMaxRegularAmount() ?: false; } return $this->maxRegularAmount; } /** * Get max regular amount * * @return \Magento\Framework\Pricing\Amount\AmountInterface */ protected function doGetMaxRegularAmount() { $maxAmount = null; foreach ($this->getUsedProducts() as $product) { $childPriceAmount = $product->getPriceInfo()->getPrice(self::PRICE_CODE)->getAmount(); if (!$maxAmount || ($childPriceAmount->getValue() > $maxAmount->getValue())) { $maxAmount = $childPriceAmount; } } return $maxAmount; } /** * {@inheritdoc} */ public function getMinRegularAmount() { if (null === $this->minRegularAmount) { $this->minRegularAmount = $this->doGetMinRegularAmount() ?: parent::getAmount(); } return $this->minRegularAmount; } /** * Get min regular amount * * @return \Magento\Framework\Pricing\Amount\AmountInterface */ protected function doGetMinRegularAmount() { $minAmount = null; foreach ($this->lowestPriceOptionsProvider->getProducts($this->product) as $product) { $childPriceAmount = $product->getPriceInfo()->getPrice(self::PRICE_CODE)->getAmount(); if (!$minAmount || ($childPriceAmount->getValue() < $minAmount->getValue())) { $minAmount = $childPriceAmount; } } return $minAmount; } /** * Get children simple products * * @return Product[] */ protected function getUsedProducts() { return $this->getConfigurableOptionsProvider()->getProducts($this->product); } /** * @return \Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsProviderInterface * @deprecated 100.1.1 */ private function getConfigurableOptionsProvider() { if (null === $this->configurableOptionsProvider) { $this->configurableOptionsProvider = ObjectManager::getInstance() ->get(ConfigurableOptionsProviderInterface::class); } return $this->configurableOptionsProvider; } }