I am fetching cart item on following .phtml file


by using the below code

$cart = Mage::getModel('checkout/cart')->getQuote();
echo "<pre>";print_r($cart->getData());echo "</pre>";

I get an array of cart item but when I use the below code

foreach ($cart->getAllItems() as $item) {
   echo "<pre>";print_r($item->getData());echo "</pre>";

then on the frontend the page keeps loading for some time and then returns nothing.

I'm not getting anything just an empty white screen.

Nothing loads on the page. But when I use this

foreach ($cart->getAllItems() as $item) {
   echo $item->getProductId();

then I get the ids of the products in the cart. Could anyone tell me the reason why it is happening, why getData() is not working but I am able to use getProductId() or getProductName().

1 Answer 1


You should try:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.