0

If I add a translation for an attribute entity my views display duplicates products. I've tried to find an attributes delta filter, but there is none. If I add a relationship for the attributes there is still no delta available in filters. Even if there was, I would need to add a relationship and filter for each attribute entity which would result in a rather massive view. I have also tried distinct views query and it does not work. How can I filter my product views on attributes language delta or another way to eliminate the duplicates?

1
  • i should add that this happens when the product variations relationship is enabled. Sep 28, 2017 at 9:24

1 Answer 1

1

I found a way to solve this. You must:

1) ensure you have a variations delta filter set.

2) add the field variations and ensure that the Display all values in the same row is NOT CHECKED under Multiple Field Settings. you can then hide this field if you do not want to display the output.

3) in the view display's Query settings tick the check box Distinct.

This configuration will remove product duplicates when the Product Variation relationship is used. This is the resulting query, i am not sure how efficient this configuration is but at least it works.

SELECT DISTINCT commerce_product__variations.delta AS commerce_product__variations_delta, commerce_product__variations.langcode AS commerce_product__variations_langcode, commerce_product__variations.bundle AS commerce_product__variations_bundle, commerce_product__variations.variations_target_id AS commerce_product__variations_variations_target_id, commerce_product_field_data.product_id AS product_id, commerce_product_variation_field_data_commerce_product__variations.variation_id AS commerce_product_variation_field_data_commerce_product__vari FROM {commerce_product_field_data} commerce_product_field_data LEFT JOIN {commerce_product__variations} commerce_product__variations ON commerce_product_field_data.product_id = commerce_product__variations.entity_id AND (commerce_product__variations.deleted = '0' AND commerce_product__variations.langcode = commerce_product_field_data.langcode) LEFT JOIN {commerce_product_variation_field_data} commerce_product_variation_field_data_commerce_product__variations ON commerce_product__variations.variations_target_id = commerce_product_variation_field_data_commerce_product__variations.variation_id WHERE commerce_product__variations.delta = '0'

Your Answer

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

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