-1
我試圖根據每個類別獲取用戶購物車中物品的數量。任何幫助將不勝感激。Magento按類別獲取購物車中的物品數量
我試圖根據每個類別獲取用戶購物車中物品的數量。任何幫助將不勝感激。Magento按類別獲取購物車中的物品數量
看看@Magento: limit 3 products from category per order
.....
$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();
}
}