1

I am developing an online shopping website using Drupal Commerce.

In my products teaser display all my products variations are also shown. I want only the main product to be displayed and not its variations on teaser display. Right now I am using in-build taxonomy term view to display my product teaser.

Any suggestions?

2 Answers 2

3

Fortunately I got the answer, by looking at the solution described in a comment to View of products with multi-value product reference field show multiple rows per product node. Here is a summary of it:

I created a view of product display nodes. Added the relationship to products. Added two fields "Content: Title" and "Commerce Product: Image". Got a row for every display node and product (so a node that references two products gets two rows). This is what I expect to happen.

Possible solution A:

I click on "Query settings" in the third column, and in query settings enable "Distinct" (it's a checkbox). That kills the duplicates.

However, DISTINCT is usually a bit stupid, so it might not work in all cases. In those cases, you can try the next possible solution.

Possible solution B:

I enable Aggregation (again, it's in the third column). I make sure to have a "Content: Nid" field added at the top of the fields list, so that it groups by that first. Might need to apply "MIN' to the title (by setting: Aggregation type to "Minimum" in "Aggregation settings" for that field).

Note that once you do that, the image will stop displaying. The solution for that is to go into "Aggregation settings" for the image field, and change the "Group column" from "fid" to "Entity ID". That makes it display again.

0
0

You may want to try what's below, based on what I found in a comment to "View of products with multi-value product reference field show multiple rows per product node".

Create a view of product display nodes. Add the relationship to products. Add two fields "Content: Title" and "Commerce Product: Image". So that you get a row for every display node and product (so a node that references two products gets two rows). Here are possible solutions for it:

  1. Click on Query settings (in the 3rd column), and in query settings enable "Distinct" (it's a checkbox). That removes the duplicates.

    However, DISTINCT is usually a bit stupid, so it might not work in all cases. In those cases, you can try another possible solution, as detailed below.

  2. Enable Aggregation (in the 3rd column). Make sure to have a "Content: Nid" field added at the top of the fields list, so that it groups by that first. You may need to apply 'MIN' to the title (by setting Aggregation type to Minimum in "Aggregation settings" for that field).

    Note that once you do that, the image will stop displaying. The solution for that is to go into "Aggregation settings" for the image field, and change the "Group column" from "fid" to "Entity ID". That makes it display again.

Your Answer

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

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