How can get Final Price, with applied price rule in Magento

我与影子孤独终老i 提交于 2019-11-29 13:55:58

问题


For example

$_producte = Mage::getModel('catalog/product')->load(2974);
echo $_producte->getFinalPrice();

I can get in frontend when insert to .phtml

BUT I can not get final price (with discount) in admin section or in custom product export file.


回答1:


Price calculation in Magento is a hot mess. You need to load the frontend event area in order to trigger rule calculation (ref Mage_CatalogRule_Model_Observer::processFrontFinalPrice() configured in Mage_CatalogRule config.xml).

Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_FRONTEND,Mage_Core_Model_App_Area::PART_EVENTS);



回答2:


I think its not necessary to load the frontend event area part. Often the product is not instanced correctly.

Try:

$product
    ->setStoreId(1) //your store_id here
    ->setCustomerGroupId(1) //your favorite customer group id here
    ->load($productId)

and then:

$product->getFinalPrice()

should give the correct final price.

Otherwise try the solutions given here: https://stackoverflow.com/a/14096072/2787671



来源:https://stackoverflow.com/questions/9684964/how-can-get-final-price-with-applied-price-rule-in-magento

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