3/09/2011

How to get all cart items from cart session in magento

This is one of the most usefull features for all magento developers.As it's very necessary while anybody working on Magento cart or checkout page.To get all cart item from cart session write the below code

$session= Mage::getSingleton('checkout/session');
foreach($session->getQuote()->getAllItems() as $item)
{
   $productid = $item->getProductId();
   $productsku = $item->getSku();
   $productname = $item->getName();
   $productqty = $item->getQty();
}

4 comments:

  1. really nice and helps me lot...

    ReplyDelete
  2. Thx u, you safe my day

    ReplyDelete
  3. not working in magento 1.8

    ReplyDelete
  4. thanks, working nice...

    ReplyDelete