2

In a multi-website (some sort of marketplace let's say) I'm looking for a way to change the website related to an order.

When editing an order in Sales / Orders, we can see that a website is attached to any order.

I'm looking for an easy way to CHANGE (I mean "reattribute") the order to another website.

First I was considering the "duplicate" option, trying to alter the code and change the website during the process but I didn't manage to do it correctly.

So here I come, seeking for some clues.

Thanks

2

You cannot do it from the UI.
Try this:

$order = Mage::getModel('sales/order')->load($orderId);
$order->setStoreId($storeId); //set one of your store view ids from the website you need
$order->save();
0

the answer from @marius is partially correct, but to update all the related data, you'll need to get the order items and invoice as well. e.g.

$iNewStoreId = 6;
$oOrder = Mage::getModel('sales/order')->load($iYourOrderEntityId);
foreach($oOrder->getItemsCollection() as $oItem){
  $oItem->setStoreId($iNewStoreId)->save();
}
$oInvoice = $oOrder->getInvoiceCollection()->getFirstItem();
$oInvoice->setStoreId($iNewStoreId)->save();
$oOrder->setStoreId($iNewStoreId)->save();

note that the ID to load the order is the entity_id not the increment ID which is the public facing order number e.g. 100001234

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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