priceResolver = $priceResolver; } /** * {@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(); $this->maxRegularAmount = $this->doGetMaxRegularAmount() ?: false; } return $this->maxRegularAmount; } /** * Get max regular amount. Template method * * @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. Template method * * @return \Magento\Framework\Pricing\Amount\AmountInterface */ protected function doGetMinRegularAmount() { $minAmount = null; foreach ($this->getUsedProducts() 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->product->getTypeInstance()->getUsedProducts($this->product); } }