I need to get the currently products in cart to estimate how many products are in ? I used the below code but it gave me this error message > Fatal error: Call to undefined method Mage_Sales_Model_Resource_Quote_Item_Collection::getAllItems()如何在Magento中獲取購物車中的當前產品?
Code:
<?php
require 'app/Mage.php';
Mage::app();
if (!Mage::isInstalled()) {
echo "Application is not installed yet, please complete install wizard first.";
}
$cart =Mage::getSingleton('checkout/cart')->getQuote()->getItemsCollection();
foreach ($cart->getAllItems() as $item) {
$productName = $item->getProduct()->getName();
$productPrice = $item->getProduct()->getPrice();
print($item);
}