November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
OrderStatusManager works with PurchaseOrder, not IPurchaseOrder. You would need to use the try 2 approach, then save as Yoel mentioned
I tried the below code
public int SaveCartAsPurchaseOrder(ICart cart) { try { var purchaseOrder = orderRepository.SaveAsPurchaseOrder(cart); var order = orderRepository.Load<IPurchaseOrder>(purchaseOrder.OrderGroupId); var purchaseOrderProcessor = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IPurchaseOrderProcessor>(); purchaseOrderProcessor.HoldOrder(order); orderRepository.Save(order); return purchaseOrder.OrderGroupId; } catch (Exception e) { throw e; } }
Still it is not working. I saw the order in CM->ordermanagement->purchaseorder status shows as in-progress only.
Looks correct to me. Maybe just try
order.OrderStatus = OrderStatus.OnHold; // instead of purchaseOrderProcessor.HoldOrder(order);
But it should be the same...
Do you use default implementation of IPurchaseOrderProcessor?
If yes, this is how it work:
It should work, and AFAIK: no hidden flow changes order status to In Progress.
/Viet Anh
Thanks Team Order status change works,
Now I have another problem, we list the purchase order on our site for some purpose.we are using below code. After update this code not working (some old orders are retrieved but recent orders not retrieved . I can see all the orders in CM)
searchOptions.CacheResults = false; searchOptions.StartingRecord = 0; searchOptions.RecordsToRetrieve = int.MaxValue; searchOptions.Classes.Add("PurchaseOrder"); StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("OrderGroupId IN (SELECT oform.OrderGroupId From [OrderForm] oform "); sqlQuery.Append("INNER JOIN [OrderFormEx] ex "); sqlQuery.Append("ON oform.[OrderFormId] = ex.ObjectId "); if (isCounterMan) { sqlQuery.AppendFormat("WHERE ex.{0} LIKE '{1}%' ", MetaFieldNames.WLCCustomUserGroup, WLCUserGroup.Counterman); } else { sqlQuery.AppendFormat("WHERE NOT ex.{0} LIKE '{1}%' ", MetaFieldNames.WLCCustomUserGroup, WLCUserGroup.Counterman); } sqlQuery.AppendFormat("AND ex.{0} LIKE '%{1}%' ", MetaFieldNames.WLCCompanyPrefix, wlcPrefix); sqlQuery.Append("AND Status = 'OnHold')"); parameters.SqlWhereClause = sqlQuery.ToString(); PurchaseOrder[] purchaseOrderCollection = OrderContext.Current.FindPurchaseOrders(parameters, searchOptions);
Any sqlquery want to change please let me know.
Regards,
Karthik
Please provide how you solved the order status issue, can be good for future visitors! :)
I don't really like the OrderSearchOptions/OrderSearchParameters way of searching for orders, one of the reasons being you are free to add any SQL you want. The risk of that is the one you just stumbled upon, that the database table structure in epi is not "public api" level accessibility, i.e. they can change it without really telling people, because they mostly have APIs that cover it. They usually don't tho, but a bigger update that I think you've done, there might be some changes.
Without knowing exactly what's changed in the database, I think it's easiest for you to just have a look at what the query is doing vs the tables it's querying against. And to find any differences there.
Joel Actually problem was in another side of the code. order status code works well only.
Thanks Quan for a valuable recommendation,
I removed that "ONHOLD" too. but It does not return the orders.
Quan,
Yes query making some problem.Becuase i can get all orders using below method.I will look into tables maybe it has some changes.
OrderContext.Current.FindPurchaseOrdersByStatus(OrderStatus.OnHold).
commerce ver:12.5
Hi Team,
I trying to change the order status using the below code but status is not changed still shows as inprogress.
I checked in commerce manager order status is not changed. Anything I missed? Please help me out.
Regards,
Karthik