Magento – Magento 1.9 : Get final price and discount in shopping cart

magento-1.9

I need help to obtain the following data of the shopping cart products:

  • First name
  • Sku
  • quantity in the cart
  • final price (after the discount)

I have the following code to obtain that data:

Mage::getSingleton("core/session", array("name" => "frontend"));
$cart = Mage::getSingleton('checkout/session')->getQuote();
foreach ($cart->getAllItems() as $item) {
    $productName = $item->getProduct()->getName();
    $productPrice = $item->getProduct()->getPrice();
    $productSku = $item->getProduct()->getSku();
    $productQty = $item->getQty();
    $productFinalPrice = $item->getProduct()->getFinalPrice();
    $productAmountDiscount = $item->getProduct()->getDiscountAmount();
}

but when I try this code the final price and the discount returns them as null values
How can I get that data with that model?

Best Answer

discountAmount is not a product attribute. Try $item->getDiscountAmount() instead.

Related Topic