Magento 2 Bundled Product is a composite product that has a number of simple or virtual products. The price of bundled products can be either a dynamic or fixed value.
For a fixed price for a bundle product, you can enter a base price with applied taxes for it. For the dynamic price, enter the price range from least expensive to the most expensive price.
However, when you are selling such bundled products on multiple sales channels such as Facebook store where you can display only one price. At that time, you either show the minimum or the maximum price for which you need to get the price range of bundle products in Magento 2.
The below programmatic method gives the code for the same.
Method to Get the Price Range of Bundle Products in Magento 2:
<?php namespace [Vendor]\[Module]\Helper; use Magento\Framework\App\Helper\Context; use Magento\Catalog\Model\Product; class Data extends AbstractHelper { protected $product; public function __construct( Context $context, Product $product ) { $this->product = $product; parent::__construct($context); } public function getPrice($productId) { $productObj = $this->product->load($productId); $finalPrice = $productObj->getPriceInfo()->getPrice('final_price')->getValue(); $minimumPrice = $productObj->getPriceInfo()->getPrice('final_price')->getMinimalPrice()->getValue(); $maximumPrice = $productObj->getPriceInfo()->getPrice('final_price')->getMaximalPrice()->getValue(); } }
That’s how you get the bundle product price in Magento 2.
Do share the solution with fellow developers via social media.
Thank you.