Filters block produces an error when chosen the same filter name for different product types: Aliases contain duplicates

Created on 3 June 2025, 5 days ago

Problem/Motivation

If two product types have an attribute with the same name, the filters block allows choosing both filters. For example, two "variants.attributes.color" attributes.

But then, when rendering, the block produces an error:

Error message
Aliases contain duplicates: 'variants.attributes.color.en-GB'. 

We need to fix this. I see two possible solutions:
1. Group the list of filters by the name, and display in the settings as a single option, but indicate that it is related to several product types.
2. Keep the filters separately, and deduplicate on the GraphQL query stage.

Not sure what option is better.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇦🇲Armenia murz Yerevan, Armenia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @murz
  • 🇦🇲Armenia murz Yerevan, Armenia
  • 🇮🇳India abhishek@kumar

    When multiple product types have the same attribute name (e.g. variants.attributes.color), the filter block allows selecting them, but the GraphQL query fails due to duplicate aliases like variants.attributes.color.en-GB

    Fix:
    Deduplicate aliases in the generated GraphQL query by appending the product type or index (e.g. color_tshirt, color_shoes), or group filters with the same name in the UI to prevent conflicts.

  • 🇦🇲Armenia murz Yerevan, Armenia

    @abhishek@kumar, I think the first option is more straightforward, because actually, when we have in several product types an attribute with the same name, we can't just filter by the attribute for only one product type.

    For example, we have Hats with attribute "color" and Pants with the same attribute "color", and both attributes will be represented as a single facet in GraphQL, so we can't filter just by "Hats" color.

    So, let's choose the option to group the filters by the name in the block settings form then, what do you think?

  • 🇮🇳India abhishek@kumar

    You're right, since GraphQL facets are shared across product types, it makes sense to group filters by attribute name. We'll update the block settings form to show each shared attribute (like "color") as a single option, regardless of how many product types use it. This will simplify the UI and avoid duplicate alias error

  • 🇦🇲Armenia murz Yerevan, Armenia

    @abhishek@kumar, so do you want to contribute a fix for this bug? If not, @eugene_bsk is ready to work on this.

Production build 0.71.5 2024