2013-04-08 134 views

回答

0

看看@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(); 
     } 
} 
相關問題