Magento get price including tax in a none-template file

我的未来我决定 提交于 2019-12-18 16:53:12

问题


At the moment i am trying to get the product price including tax in a php file for my product feed. I have this code at the moment:

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

Problem is that since that of course the '$this->' part doesn't work so well from the file. Anyone know how i can still get the price including tax in this file?


回答1:


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());



回答2:


Thanks @Alex:

If the product has FinalPrice special price is the final price of the product to access the most serious tax base price:

    $_product = Mage::getModel('catalog/product')->load($p->getId());

    $_specialPriceIncTax = Mage::helper('tax')
        ->getPrice($_product, $_product->getFinalPrice());

    $_priceTax = Mage::helper('tax')
        ->getPrice($_product, $_product->getPrice());


来源:https://stackoverflow.com/questions/13287820/magento-get-price-including-tax-in-a-none-template-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!