我正在尝试按每个类别获取用户购物车中的商品数量。任何帮助将不胜感激。
问问题
878 次
1 回答
0
.....
$quote = Mage::getSingleton('checkout/session')->getQuote();
foreach($quote->getAllVisibleItems() as $item){
$product = Mage::getModel('catalog/product')->load($item->getId());
$product_category_ids = explode(",", $product->getCategoryIds());
//$product_category_ids = $product->getCategoryIds();
foreach($product_category_ids as $category_id){
$category_ids[$category_id]['category_id'] = $category_id;
$category_ids[$category_id]['product_count'] = ($category_ids[$category_id]['product_count']) ? $category_ids[$category_id]['product_count'] + $item->getQty() : $item->getQty();
}
}
于 2013-04-08T22:28:12.567 回答