Okay, I have no idea how to do this simple thing. All I need is to loop through the 3 items that I have currently in the cart, so I can get item information about each one - like product category, item name, blah blah blah. I have googled this for an hour already, and have not foun开发者_StackOverflow中文版d anything on what seems to be such a simple task. Getting quote, and then getAllItems() returns nothing for me. Anybody have any ideas / links?
Thanks.
Are you sure getting the quote doesn't work? The following code should work:
$session = Mage::getSingleton('checkout/session');
foreach ($session->getQuote()->getAllItems() as $item) {
print_r($item->getData());
}
Of course, if you're not doing it from inside a Magento template/controller/model then you'll need to set up the environment appropriately:
require_once 'app/Mage.php';
umask(0);
Mage::app();
/* Then put your code here.. */
- Source: http://www.nicksays.co.uk/2009/02/testing-magento-modules/
- Source: http://www.magentocommerce.com/boards/viewthread/19020/#t99651
精彩评论