i want to copy one quote (only cart items) to other quote (only items ). Only want to copy cart products to other new quote.

Suppose: i have old quote,which id is 5,have 4 items

 i have another quote which id 77, have 1 item, i want to copy  4 items of quote id  5 to 
quote id  77.

I have try below blog; Programmatically add items to cart and assign to guest user

3 Answers 3


Have a look at the merge() method in Mage_Sales_Model_Quote. I've never used it, but it should be something such as:

$quoteA = Mage::getModel('sales/quote')->load('5');
$quoteB = Mage::getModel('sales/quote')->load('77');


// Also?


// edit - I looked at what Magento does in the checkout session model, and it also calls collectTotals() and save(), so that's probably necessary as well.

Have a look also at Mage_Checkout_Model_Session

  • All data is saved in quote tables successfully after merge. But the checkout/cart page shows that 'Cart is empty'. Any idea how to solve this?
    – Arvind07
    Commented Feb 6, 2016 at 6:36
  • Hi @Arvind07, Have you solved this issue? Commented Jul 2, 2018 at 10:13

Just an addition to this, to get the quote items copied over, you need to run the following:

foreach($quoteA->getItemsCollection() as $item) {

   $item->setId(null); //Remove the item id, so it gets added

I had a similar problem, I wanted to create a new quote in the user's session and copy previous items to it, and it worked for me.

$newQuote = Mage::getModel('sales/quote')->merge($quote);

Your Answer

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

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