Skip to content

Invalid Facet Aggregation Behavior in GraphQL products Query — Variations Are Not Included in Term Facets #80

@AhmedElmehalawi

Description

@AhmedElmehalawi

Description

When using the GraphQL products query in Virto Commerce to search for products with filters, an unexpected and invalid behavior occurs with term facets aggregation.

By default, the query automatically applies the filter: is:product

This correctly limits the results to main products only (excluding variations).
However, this same filter is also being applied to the term facets aggregation, which causes the facets to include only the main products and ignore variations.

As a result, attributes like Size, Color, etc., show incomplete or incorrect filtering options.

Example Scenario

Product Data

  • Main Product: Size S
  • Variations: Sizes M, L, XL

Current Behavior

  • Returned products: ✅ Only the main products
  • Returned facets: ❌ Only include Size S (missing M, L, XL)

Expected Behavior

  • Returned products: ✅ Only main products (as per is:product)
  • Returned facets: ✅ Include attributes aggregated across both main products and their variations.

Impact

This leads to invalid filtering data on the storefront.
For example, the size filter will only show “S” even though the product has available sizes “M, L, XL” as variations.
It results in a poor and misleading shopping experience for customers.

Suggested Solution

Introduce a boolean argument in the products GraphQL query to control how facet aggregation is computed.

Current Workaround

The only available workaround is to run two separate GraphQL queries:

  1. Query 1: With is:(product,variation) to get correct term_facets
  2. Query 2: With is:product to get main product listings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions