0

I like to achieve below solution using Drupal configuration instead of code.

The commerce module has been installed for one of our Drupal CMS site. In the admin interface there is an Orders view for the Commerce module. This view basically shows all orders placed by users on the website.

Within this view I like to add Product SKU field as one of the search filter. I noticed SKU field exists in the Product variations table that is child table of the Products table. And Product table is linked to Order Item table. And Order Item is the child table of Orders table. This is something I checked on the MySQL DB database table relations otherwise I don't know how to find our such relationships from Drupal admin interface.

I went to EDIT section for the Orders view. Then clicked on Add button for Advanced >> Relationship but can't find find any product or product variation entity there. So not sure how to achieve the solution of my problem?

Can you please help?

Looking forward to getting your reply.

Thanks - Hitesh

1

Ok you all most did it !

first in the view you need to add the "Order item referenced from order_items" relationship

in your view ->advanced RELATIONSHIPS...

after this you can then add the "Product variation" relationship.

with the 2 relationships added to the view you can now add the exposed filter you require.

|improve this answer|||||
  • Thanks for your help. It is working for me now. – Hitesh Mar 14 '19 at 6:04
  • thank you, made it work for me as well, in Ubercart. Just requires the two relationships. – Morten H Sep 9 '19 at 10:08
0

I just wanted to comment on here about what to do if you're using the D7 version and come across this post (like we did). Here's the two relationships you will need to add in order to have SKU as a filter:

Commerce Order: Referenced line items

Commerce Line item: Referenced products

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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