[SOLVED][Drupal Commerce] Adding a multi value product reference field in a View of products produces duplicates.

| | 1 min read

Many Drupal users using the Drupal Commerce module encountered a situation in which adding a multi value product reference field in a View of products produces duplicates. If you are facing the same situation with Drupal Commerce in your Drupal site then read on to know the fix.

Here is the most widely reported solution provided by a Drupal user.

  • Click on "Query Settings" (Found in the 3rd column)
  • There enable the "Distinct" checkbox"

This might not work in all cases so here is another solution

  • Enable Aggregation (Found in the 3rd column)
  • You need to have the Content: Nid field added at the top of the fields list
  • This is to ensure that it groups by that first
  • Next go to Aggregation settings for that field and set Aggregation type to "Minimum"
  • Now you might notice that the image will stop being displayed
  • To fix the image issue go to Aggregation Settings for the image field
  • There change the "Group column" from "fid" to "Entity ID"
  • Now you will see the image display again

Hope that helps.

The easiest way to solve a Drupal issue is to hand it to the Drupal experts. We can provide a wide range of Drupal services to help you maintain and manage your Drupal websites. Get in touch with us to know more.