Try our conversational search powered by Generative AI!

Extract orders related to specific supplier in a many to many B2B scenario

Vote:
 

Hi,

Usually, you have the screnario where "Company X" sells to n numbers of customers. When loading a customers orders, you do:

_orderRepository.Load<IPurchaseOrder>(customerId);

However, in our solution, we need to support n numbers of suppliers selling to n numbers of customers. One order can contain articles from different suppliers. Loading the customers orders we can do as above, however, I'm not sure what strategy to take to load the all orders related to a supplier.

Currently, a reference to the supplier is stored on the line item in commerce.

Does anyone have any input, tips or trix in regards to a good solution to extract orders related to one specific supplier? I came across the "OrderSearchOptions", would that be a good option?

Thanks!

/Jessica

#202492
Edited, Mar 27, 2019 13:42
Vote:
 

Hi - yes, for now OrderContext.Search is your best bet. We are working on search using abstraction APIs (IOrderSearch), however it is still a long way ahead. 

Sounds like you can search for orders that contains items from a specific supplier by this

var searchParameters = new OrderSearchParameters();

//other things

searchParameters.SqlWhereClause= $" OrderGroupId in (SELECT OrderGroupId From LineItem li INNER JOIN LineItemEx lie ON li.LineItemId = lie.ObjectId WHERE lie.Supplier = {supplier}) ";

//Search 

Two notes:

#202493
Edited, Mar 27, 2019 14:20
Vote:
 

Great! Thanks Quan!

This forum is great! <3

#202495
Mar 27, 2019 14:41
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.