Skip to content

Commit

Permalink
Merge pull request #130 from riha112/3474
Browse files Browse the repository at this point in the history
[3474] Min price for config product
  • Loading branch information
carinadues authored Oct 25, 2021
2 parents 886300a + 2948974 commit 1a97bc2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Model/Resolver/Product/PriceRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Store\Api\Data\StoreInterface;
use Magento\CatalogGraphQl\Model\Resolver\Product\PriceRange as CorePriceRange;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;

/**
* Format product's pricing information for price_range field
*/
class PriceRange extends CorePriceRange
{
const XML_PRICE_INCLUDES_TAX = 'tax/calculation/price_includes_tax';
const FINAL_PRICE = 'final_price';

/**
* @var float
Expand Down Expand Up @@ -127,7 +129,13 @@ protected function getMinimumProductPrice(SaleableInterface $product, StoreInter
$priceProvider = $this->priceProviderPool->getProviderByProductType($product->getTypeId());

$regularPrice = (float) $priceProvider->getMinimalRegularPrice($product)->getValue();
$finalPrice = (float) $priceProvider->getMinimalFinalPrice($product)->getValue();
$finalPrice = 0;

if ($product->getTypeId() === Configurable::TYPE_CODE) {
$finalPrice = $product->getPriceInfo()->getPrice(self::FINAL_PRICE)->getValue();
} else {
$finalPrice = (float) $priceProvider->getMinimalFinalPrice($product)->getValue();
}

$discount = $this->calculateDiscount($product, $regularPrice, $finalPrice);

Expand Down

0 comments on commit 1a97bc2

Please sign in to comment.