1

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 );
                            }  
  • use my updated answer. – liyakat Sep 20 '13 at 10:10
2

The price of a bundled product is calculated in the class Mage_Bundle_Model_Product_Price, in the function getFinalPrice() to be exact. When you look into this function you’ll notice two lines in particular:

$finalPrice = $product->getData('final_price');
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
$finalPrice += $this->getTotalBundleItemsPrice($product, $qty);

And for tax

You can get a helper-instance in any file using:

Mage::helper('tax')

Your full code is:

$_product = Mage::getModel('catalog/product')->load($productId);
$_priceIncludingTax = Mage::helper('tax')
    ->getPrice($_product, $_product->getFinalPrice());

EDIT

or you can also use direct function to display price with tax

Mage::getModel('bundle/product_price');
public function getTotalPrices($product, $which = null, $includeTax = null, $takeTierPrice = true)

See for calculation

hope this will sure help you.

0

I found a work around to getting price including tax.

pass product object in this function to get bundle product price inclusive of tax

Mage::getModel('bundle/product_price');
public function getTotalPrices($product, $which = null, $includeTax = null, $takeTierPrice = true)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.