Creating historical orders - inserting with OrderID

Vote:
 

I need to import historical orders into a new episerver build. The old orders already have an order ID, is it possible to create orders with a specific order ID? 

#221347
Apr 16, 2020 16:29
Vote:
 

Do you want to keep order id same? That's what you want or you want your custom OrderId to be instered while creating PurchaseOrder?

var purchaseOrderLink = _orderRepository.SaveAsPurchaseOrder(cart);
var purchaseOrder = _orderRepository.Load<IPurchaseOrder>(purchaseOrderLink.OrderGroupId);

_purchaseOrderProcessor.ProcessOrder(purchaseOrder);
purchaseOrder.OrderStatus = OrderStatus.Completed;
purchaseOrder.OrderNumber = "My Custom Order Number";

This is how you can add your custom order number to a Purchase Order.

#221391
Apr 17, 2020 9:37
Vote:
 

I believe Noel wants to keep the OrderGroupId. I don't think that's possible without some nasty hacks 

#221392
Apr 17, 2020 9:41
Vote:
 

@Praful, are all properties editable in that fashion? if everything is editable i dont mind what initial id it uses

@Quan, I think I have some confusion between order numbers and order group ids, the customers old system will be providing an orderId or order number, and i need to insert all those orders as if they were bought via episerver from the start, so no difference between legacy inserted orders and newly created orders.

I've discovered the ServiceAPI: https://world.episerver.com/documentation/class-libraries/rest-apis/service-api/#/Order/Order_PostOrder

it looks like that lets me insert the OrderNumber? 

#221394
Apr 17, 2020 9:48
Vote:
 

if you meant the order number, then Yes, you can (via ServiceAPI).

IPurchaseOrder.OrderNumber and PurchaseOrder.TrackingNumber are basically the same thing, and can be set/updated 

#221412
Apr 17, 2020 14:40
Noel Sefton - Apr 17, 2020 14:44
i think i mean 'OrderGroupId' but I'm thinking maybe old legacy orders may just need a bit of extra metadata if i cant edit that value very easily
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.