Creating historical orders - inserting with OrderID


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? 

Apr 16, 2020 16:29

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);

purchaseOrder.OrderStatus = OrderStatus.Completed;
purchaseOrder.OrderNumber = "My Custom Order Number";

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

Apr 17, 2020 9:37

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

Apr 17, 2020 9:41

@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:

it looks like that lets me insert the OrderNumber? 

Apr 17, 2020 9:48

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 

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.