How to configurable Child product cost price get in magento 2
-
06-05-2021 - |
Frage
How to get configurable child cost price get in magento 2.
Thanks.
Keine korrekte Lösung
Andere Tipps
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.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange