Magento 1.9 – Get Product Price After Discount Applied

csvcustomermagento-1.9price

I tried to get the product price after a catalog price rules was applied and i can't.

The code that i use to do this:

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

    //get promo_price
    $promo_price = Mage::getModel('catalogrule/rule')->calcProductPriceRule($product,$product->getPrice());

and this:

$promo_price = $product->getPrice() - $product->getDiscountAmount();

But this code returns me NULL.

Does anyone know how can i do this?

Best Answer

We use this to get an updated product price

<?php
$_product->getPrice();

$_product->getFinalPrice();

//Here you can get the catalog rule applied price like:
$store_id = Mage::app()->getStore()->getId();
$discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice(
    Mage::app()->getLocale()->storeTimeStamp($store_id),
    Mage::app()->getStore($store_id)->getWebsiteId(),
    Mage::getSingleton('customer/session')->getCustomerGroupId(),
    $_product->getId()
);


if ($discountedPrice === false) { // if no rule applied for the product
    $discountedPrice = $_product->getFinalPrice();
} else {
    $discountedPrice = number_format($discountedPrice,2);
}
Related Topic