0

Sorry if the title is a little vague, I don't know how else to describe it in the space.

I have a view that shows Drupal Commerce orders. I am trying to add the SKUs of each product in an order as a field for filtering reasons. However, when I add a relationship to reference line items in the orders, I end up with duplicate rows, one for every line item in an order. I've tried aggregation and making queries distinct, neither of which do what I want.

2

Do this:

Add relationships:
1. Commerce Order: Referenced line items
2. Commerce Line item: Referenced products

In Other set Set Aggregation to Yes

Include fields:
1. Commerce Line Item: Line item ID, set aggregation to COUNT and tick Exclude from display
2. Commerce Product: SKU, set aggregation to COUNT and tick Exclude from display.

Add a Filter criteria:
1. Commerce Product: SKU. Expose it to the visitor to your liking, and leave aggregation type to Group results together.

Now you will have only one row returned with no duplicates and you can filter SKU

| improve this answer | |
  • You are a genius, thank you! Not entirely sure how it works though... – Koozer Apr 30 '14 at 11:37

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.