Question

How to get configurable child cost price get in magento 2.

Thanks.

No correct solution

OTHER TIPS

You get cost price of child product like below.

$configProduct = $objectManager->create('Magento\Catalog\Model\Product')->load($product_id);
 
$_children = $configProduct->getTypeInstance()->getUsedProducts($configProduct);
$price = 0;
foreach ($_children as $child){
    $price = $price + $child->getPrice();
}
echo "Total Price:". $price;

If you want price range of configurable product then you can do it by below

<?php
$currentProduct = $this->getProduct();
$regularPrice = $currentProduct->getPriceInfo()->getPrice('regular_price');
?>
<div class='price-box'>
    <span class="price">
        <?php
            echo $regularPrice->getMinRegularAmount().'-'.$regularPrice->getMaxRegularAmount();
        ?>
    </span>
</div>

Please check and let me know if you have any query.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top