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.

1 Answer 1

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

1
  • You are a genius, thank you! Not entirely sure how it works though... Commented Apr 30, 2014 at 11:37

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.