I want to get the shopping cart details, by using Magento's getQuote
function. How can I do this?
$cart = Mage::getModel('checkout/cart')->getQuote();
When I print the $cart
Page stops execution and blank page is shown.
But when I write
$cart = Mage::getModel('checkout/cart')->getQuote()->getData();
and print the $cart
an array will show. But I want to track the complete cart data (product Id,Product price like all information).
Is there any other method by which I can find the shopping card data?
Best Answer
The object returned by
getQuote
is aMage_Sales_Model_Quote
. It has a methodgetAllItems
which in turn returns a collection ofMage_Sales_Model_Quote_Item
objects.All this means you can inspect products like this:
PS. The reason you get a blank page is because dumping a whole object likely fell into recursion and the page timed out, or PHP ran out of memory. Using
getData
ordebug
is safer but, as you saw, doesn't return the protected/private variables.