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

2

9

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.

Badoglio answered 13/3, 2012 at 13:31 Comment(0)
A
12

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);
Armond answered 13/3, 2012 at 13:54 Comment(4)
What about processAdminFinalPrice?Misery
What about it? Sounds like a new question to me :-) - perhaps here or over at magento.stackexchange.comArmond
Well, that's true but I was surprised why rule calculation triggered by processFrontFinalPrice, Can't it be possible with processAdminFinalPrice? Can ask in separate question.. :)Misery
FWIW I've learned to be surprised by nothing when it comes to Magento price/totals calculation, unfortunately...Armond
A
3

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://mcmap.net/q/629478/-magento-how-to-get-the-price-of-a-product-with-catalog-rules-applied

Asymmetry answered 1/9, 2017 at 9:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.