且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取Magento的购物车详细信息

更新时间:2023-11-30 12:03:28

getQuote返回的对象是 getAllItems ,该方法反过来返回 Mage_Sales_Model_Quote_Item 对象.

The object returned by getQuote is a Mage_Sales_Model_Quote. It has a method getAllItems which in turn returns a collection of Mage_Sales_Model_Quote_Item objects.

所有这些意味着您可以检查以下产品:

All this means you can inspect products like this:

$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
    $productId = $item->getProduct()->getId();
    $productPrice = $item->getProduct()->getPrice();
}

PS.您得到空白页的原因是因为转储整个对象可能会导致递归并且页面超时,或者PHP内存不足.使用getDatadebug较为安全,但是如您所见,不会返回受保护/私有变量.

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 or debug is safer but, as you saw, doesn't return the protected/private variables.