I am trying to get product prices both inclusive and exclusive tax in custom export script.
To get product price with inclusive tax I used this code.
Mage::helper('tax')->getPrice($_product, $_product->getPrice());
This working fine for simple product.
But For Bundle product how we can get price inclusive tax.
Bundle product price type is dynamic.
And I have used this code to retrieve bundle product price.
$bundlePriceModel = Mage::getModel('bundle/product_price');
$selectionCollection = $_product->getTypeInstance(true)->getSelectionsCollection(
$_product->getTypeInstance(true)->getOptionsIds($_product), $_product
);
$itemPrice = 0;
foreach($selectionCollection as $_option) {
$itemPrice += $bundlePriceModel->getSelectionFinalTotalPrice($_product, $_option,1, $_option->getData('selection_qty'), true, true );
}
Best Answer
The price of a bundled product is calculated in the class
Mage_Bundle_Model_Product_Price
, in the functiongetFinalPrice()
to be exact. When you look into this function you’ll notice two lines in particular:And for tax
You can get a helper-instance in any file using:
Your full code is:
EDIT
or you can also use direct function to display price with tax
See for calculation
hope this will sure help you.