Magento – How to get the price range of bundle products in Magento 2

bundled-productmagento2price

How can I get the price range of bundle products? It's complicated as the bundle product can have different settings e.g. fixed price / dynamic price?

I tried to take Magento's core code as an example, but I failed to trace it as the price range is rendered in a _toHtml() function.

Any suggestion is welcome.

Best Answer

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Catalog\Model\Product')->load(YOUR_ID);
$bundleObj=$product->getPriceInfo()->getPrice('final_price');
echo $bundleObj->getMinimalPrice();// For min price
echo $bundleObj->getMaximalPrice(); // for max price

Note: I am against of direct loading object with objectManager, for better impact you can inject it in your constructor

Related Topic