예제 #1
0
 /**
  * {@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 getValue()
 {
     $selectedConfigurableOption = $this->product->getSelectedConfigurableOption();
     $productId = $selectedConfigurableOption ? $selectedConfigurableOption->getId() : $this->product->getId();
     if (!isset($this->values[$productId])) {
         $this->values[$productId] = $this->priceResolver->resolvePrice($this->product);
     }
     return $this->values[$productId];
 }
 /**
  * @param \Magento\Framework\Pricing\SaleableInterface|\Magento\Catalog\Model\Product $product
  * @return float
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)
 {
     $price = null;
     foreach ($this->configurable->getUsedProducts($product) as $subProduct) {
         $productPrice = $this->priceResolver->resolvePrice($subProduct);
         $price = $price ? min($price, $productPrice) : $productPrice;
     }
     if (!$price) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Configurable product "%1" do not have sub-products', $product->getName()));
     }
     return (double) $price;
 }
 /**
  * @param \Magento\Framework\Pricing\SaleableInterface $product
  * @return float
  */
 public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)
 {
     $selectedConfigurableOption = $product->getSelectedConfigurableOption();
     if ($selectedConfigurableOption) {
         $price = $this->priceResolver->resolvePrice($selectedConfigurableOption);
     } else {
         $price = null;
         foreach ($this->configurable->getUsedProducts($product) as $subProduct) {
             $productPrice = $this->priceResolver->resolvePrice($subProduct);
             $price = $price ? min($price, $productPrice) : $productPrice;
         }
     }
     $priceInCurrentCurrency = $this->priceCurrency->convertAndRound($price);
     return $priceInCurrentCurrency ? (double) $priceInCurrentCurrency : false;
 }