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

up vote 7 down vote accepted

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 Feb 6 '16 at 6:36
  • Hi @Arvind07, Have you solved this issue? – Ramkishan Suthar Jul 2 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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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