2012-11-08 42 views
6

目前我正试图在我的产品Feed的php文件中获得包含税款的产品价格。我有此代码的那一刻:Magento在非模板文件中获得包含税款的价格

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

问题是,由于该课程的“$这个 - >”部分没有从文件工作这么好。 任何人都知道我仍然可以在此文件中获得含税的价格?

回答

27

您可以在任何文件中使用得到帮助,比如:

Mage::helper('tax') 

你完整的代码:

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

感谢@Alex:

如果产品有FinalPrice特惠价是产品进入最严格的税基价格的最终价格:

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

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

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