0

I need to create a filter on sales admin order grid that only shows the orders that contain products from a specific source.

I found questions that sort of answered this for Magento 1 but not for Magento 2. Most of the solutions add a custom column to the grid and filter on that.

I need this filter to be executed on page load. If the order contains products from source A, the admin should not be able to see orders for products from source B in the grid.

1 Answer 1

0

how do you see this functionality working? As you don't have direct Relationship between Order and Sources. What we have is Order to a Stock relationship (based on the website where this order has been placed).

What we will have are Shipments (created in the scope of order fulfillment) assigned to a particular source. So, we introduce Order to Source linkage via Shipping process

3
  • The products that are part of the order have a direct relation with the source. From the order id, I should be able to find out which products are part of the order and if it is not from source X, I don't want to show that order in the list. If not, how can I create a default filter that would show orders for a particular website?
    – coderGeek
    Commented May 1, 2019 at 14:21
  • "The products that are part of the order have a direct relation with the source" - that's not exactly right. Because this relation appears only for those orders for which we have Shipment created because the Shipment process establishes this relation. Before that - the system does not have a clue which source would be used for fulfillment. "how can I create a default filter that would show orders for a particular website?" - This data already shown on Order grid in "Purchase Point" column - if you need to do it programmatically use - \Magento\Sales\Api\OrderRepositoryInterface::getList Commented May 2, 2019 at 20:01
  • I do need to do it programmatically but I am very new to Magento and don't really know how to do this such that the moment the orders grid is loaded, it only shows orders from a particular purchase point. Can you please help me with the starter code. Thanks!
    – coderGeek
    Commented May 3, 2019 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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