Magento: Get the quantity in cart for a given product

前端 未结 4 651
鱼传尺愫
鱼传尺愫 2021-01-31 06:31

I use this code :

// $items = Mage::getModel(\'checkout/cart\')->getQuote()->getAllItems();
$items = Mage::getSingleton(\'checkout/session\')->getQuote(         


        
4条回答
  •  梦谈多话
    2021-01-31 06:57

    You should use the

    setQUote
    

    method when calling the collection. Should looks like this

    $quote = Mage::getModel('sales/quote')->load($quote_id);
    $salesQuoteItem = Mage::getModel('sales/quote_item')->getCollection()
                ->setQuote($quote)
                ->addFieldToFilter('quote_id', $quote_id)
                ->addFieldToFilter('product_id', $data['product_id'])
                ->getFirstItem();
    

提交回复
热议问题