Hi I was trying to remove an item from the sales quote item.

$quoteItemCollection = Mage::getModel('sales/quote_item')->getCollection()->addFieldToFilter('quote_id', $quoteId)->addFieldToFilter('product_id', $product_id)->getFirstItem();;
    $itemId = $quoteItemCollection->getItemId();

This is returning me the following error.

{"messages":{"error":[{"code":0,"message":"Invalid method Mage_Sales_Model_Quote_Item::removeItem(Array\n(\n [0] => 1355\n)\n)"}]}}

If this is not the way,is there any other way to do or what made me wrong here.Please help.

3 Answers 3


try below code because save method doesnot work with collection

$quote = Mage::getModel('sales/quote')->load(quote_id);
// get item id by your logic 

removeItem method code

public function removeItem($itemId)
    $item = $this->getItemById($itemId);

    if ($item) {
         * If we remove item from quote - we can't use multishipping mode
        if ($item->getHasChildren()) {
            foreach ($item->getChildren() as $child) {

        $parent = $item->getParentItem();
        if ($parent) {

        Mage::dispatchEvent('sales_quote_remove_item', array('quote_item' => $item));

    return $this;
  • I have tried a different function where save worked for collection ,To update qty in sales item
    – Melvin
    Feb 22, 2017 at 13:25
  • @Melvin try above code and let me know Feb 22, 2017 at 13:31
  • returning the same error
    – Melvin
    Feb 22, 2017 at 13:34
  • @Melvin check updated code Feb 22, 2017 at 13:45
  • This is working now however the sales quote qty is not getting deducted.IShould I need to add a different logic or this code will take care ?
    – Melvin
    Feb 22, 2017 at 14:01

Use below code :

$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();        
foreach ($items as $item) 
   $itemId = $item->getItemId();

Try the bellow code:

 $quote = Mage::getModel("sales/quote");
     foreach($quoteItems as $oneItem){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.