Shopify graphql filter by tag is not working

Solved

Shopify graphql filter by tag is not working

Tsredi
Shopify Partner
12 1 5

Hey guys I'm trying to filter products by tag name but its not working:

{
collections(first:100){
nodes{
products(filters:[{tag:"Abstract"}],first:100){
nodes{
title
tags

}
}
}
}
}

 

it still returns full list of products

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 238 508

This is an accepted solution.

Hey @Tsredi

 

Just taking a look here. The first thing I would check is to make sure you've met the requirements for filtering products on the storefront API. What stands out to me is the requirement to install the Search and Discovery app to enable the additional filters. Without that, the filter arguments would be ignored. 

 

- https://shopify.dev/docs/custom-storefronts/building-with-the-storefront-api/products-collections/fi... 

 

Hope that helps! 

 

- Kyle G.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 5 (5)

lizk
Shopify Staff
246 58 78

Hi there 👋

If you are using the Admin API or Storefront API you can specify the tag in the query param. It would look something like this. 

 

 

 

 

{
  products(first: 10, query:"tag:Premium") {
    nodes {
      id
      handle
    }
  }
}

 

 

If you are trying to build a filtering experience with the storefront API, and not just retrieve products with a certain tag, I would recommend reviewing this in depth tutorial on filtering products.

 

To learn more visit the Shopify Help Center or the Community Blog.

Tsredi
Shopify Partner
12 1 5

Hey, I know that it works that way but I'm trying to filter products under collections

Tsredi
Shopify Partner
12 1 5

@Tsredi wrote:

Hey, I know that it works that way but I'm trying to filter products under collections




ShopifyDevSup
Shopify Staff
1453 238 508

This is an accepted solution.

Hey @Tsredi

 

Just taking a look here. The first thing I would check is to make sure you've met the requirements for filtering products on the storefront API. What stands out to me is the requirement to install the Search and Discovery app to enable the additional filters. Without that, the filter arguments would be ignored. 

 

- https://shopify.dev/docs/custom-storefronts/building-with-the-storefront-api/products-collections/fi... 

 

Hope that helps! 

 

- Kyle G.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Tsredi
Shopify Partner
12 1 5

Thanks, that's what I was missing