How to Get Configurable Product Price Range in Magento 2

Hello everybody, couple of days back I got a prerequisite in which I have to show the Price Range of Configurable Product. I figured I should get all the related items and after that get the Minimum Price and Maximum Price. After some exploration in Magento Configurable Product Module I got a major lead. Fortunately Magento gives the strategy to getting the Minimum and Maximum Price. In this Post we will perceive how we can get the Range in layout record.

In your module structure make a format document catalog_product_view_type_configurable.xml, for my situation the record way is application/code/Ikodes/PriceRange/see/base/design/catalog_product_view_type_configurable.xml

<?xml version="1.0"?>
<page xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="">
            <block class="Magento\ConfigurableProduct\Block\Product\View\Type\Configurable" name=""  template="Webkul_PriceRange::product/price_range.phtml" />

Now, we will create template file price_range.phtml at
path app/code/Ikodes/PriceRangeCustomisation/view/base/templates/

$currentProduct = $this->getProduct();
$regularPrice = $currentProduct->getPriceInfo()->getPrice('regular_price');
<div class='price-box'>
    <span class="price">
            echo $regularPrice->getMinRegularAmount().'-'.$regularPrice->getMaxRegularAmount();
Likewise, the strategies getMinRegularAmount() and getMaxRegularAmount() restores the cost of In Stock related items as it were. For further investigation the technique definition you can allude to the record

Related posts