variantOption - Unexpected behavior when using filters in collections

Topic summary

Users are experiencing issues filtering product variants in Shopify collections using the variantOption filter in the Storefront API. Despite following official documentation and applying filters like Color: Black, the API returns all product variants instead of only the filtered ones.

Attempted Solutions:

  • Installing the “Search & Discovery App” from Shopify admin
  • Configuring filters (Color, Size, Warehouse) in the app settings
  • Following steps from a GitHub discussion about enabling product types in “Collection and search filters”

Current Status:
The issue remains unresolved. Users report that even after implementing suggested fixes, queries still return complete variant lists rather than filtered results. The discussion is seeking clarification on whether:

  • There’s a built-in Storefront API method to return only matching variants
  • Client-side filtering after fetching is the only viable approach
  • Additional configuration steps are missing

No definitive solution has been identified yet.

Summarized with AI on October 24. AI used: claude-sonnet-4-5-20250929.

Hey all, I’m trying to filter the products variants of my collections using the filters and variantOption properties. I have been following this guide from the official doc https://shopify.dev/docs/custom-storefronts/building-with-the-storefront-api/products-collections/filter-products#query-products-by-variant-options and this is the query I’m testing to fetch my data

query getCollection($idCollection: ID) {
  collection(id: $idCollection) {
    id
    title
    products(
      first: 10
      filters: { variantOption: { name: "Color", value: "Black" } }
    ) {
      edges {
        node {
          id
          title
          description
          totalInventory
          variants(first: 5) {
            edges {
              node {
                id
                title
                price {
                  amount
                }
                compareAtPrice {
                  amount
                }
                selectedOptions {
                  name
                  value
                }
              }
            }
          }
          featuredImage {
            url
          }
        }
      }
    }
  }
}

However, in my response, I get all the product variants and not just the one that I’m filtering with the variant options. I just want to know if there is something missing in my query or if there is some other way to achieve this.

1 Like

I found a similar issue here: https://github.com/Shopify/storefront-api-feedback/discussions/120

Looks like it was solved by these steps:

Did you enable the product type in the "Collection and search filters" section in the Shopify admin?

That was it. Steps to solve.
Open Store Admin -> Sales Channels -> Online Store -> Navigation
Add "Search & Discovery App" by Shopify
Now you can edit "Collection and search filters" in the app settings.

Let me know if this helped, if not I will try and recreate this.

Just add the “Search & Discovery App” in my Shopify admin but there is not a “Collection and search filters” option, there is just a filters option and I added the Color and Warehouse options in there but when testing the query it still returning all variants.

1 Like

I already tried the suggested solution (installed the Search & Discovery App and added the filters like Color and Size) but I’m still getting all the product variants in the response, not just the filtered one.

So what I really need is a way to only get the matching variant(s) back in the response rather than all of them. Do you know if there’s a built-in way to do that in Storefront API, or do I need to filter the variants manually on the client side after fetching?