If want to show price for out of stock configurable product price you need to check
vendor/magento/module-configurable-product/Pricing/Price/ConfigurablePriceResolver.php
public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)
vendor/magento/module-configurable-product/Pricing/Price/ConfigurablePriceResolver.php
Find function on line number 61
public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)
Before Editing :::
public function
resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)
{
$price =
null;
foreach
($this->lowestPriceOptionsProvider->getProducts($product) as $subProduct)
{
$productPrice = $this->priceResolver->resolvePrice($subProduct);
$price
= isset($price) ? min($price, $productPrice) : $productPrice;
}
return
(float)$price;
}
After Editing :::
public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)
public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)
{
$price =
null;
$assPrice=array();
foreach
($this->configurable->getUsedProducts($product) as $subProduct) {
$productPrice = $this->priceResolver->resolvePrice($subProduct);
$assPrice[]=$productPrice;
$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
(float)(min($assPrice));
}
Comments
Post a Comment