Unfortunately, Shopify’s Storefront API does not have a direct endpoint for filtering products by category. However, you can filter products by collection, which is a group of products that share a common theme or characteristics, and then within the collection, you can categorize the products by adding tags to each product.
Here’s a sample GraphQL query that fetches products from a specific collection and then filters them by tags:
javascriptCopy code
query { collection(handle: "collection-handle") { title products(first: 20) { edges { node { title tags ... on Product { category: tags(first: 1) { edges { node { name } } } } } } } } }
In this example, replace collection-handle with the handle of the collection you want to fetch products from. The tags field returns an array of all the tags assigned to a product, and category is a custom field that uses the tags field to only return the first tag assigned to the product, which would be used as the product’s category.
Unfortunately, Shopify’s Storefront API does not have a direct endpoint for filtering products by category. However, you can filter products by collection, which is a group of products that share a common theme or characteristics, and then within the collection, you can categorize the products by adding tags to each product.
Here’s a sample GraphQL query that fetches products from a specific collection and then filters them by tags:
javascriptCopy code
query { collection(handle: "collection-handle") { title products(first: 20) { edges { node { title tags ... on Product { category: tags(first: 1) { edges { node { name } } } } } } } } }
In this example, replace collection-handle with the handle of the collection you want to fetch products from. The tags field returns an array of all the tags assigned to a product, and category is a custom field that uses the tags field to only return the first tag assigned to the product, which would be used as the product’s category.
Unfortunately, Shopify’s Storefront API does not have a direct endpoint for filtering products by category. However, you can filter products by collection, which is a group of products that share a common theme or characteristics, and then within the collection, you can categorize the products by adding tags to each product.
Here’s a sample GraphQL query that fetches products from a specific collection and then filters them by tags:
javascriptCopy code
query { collection(handle: "collection-handle") { title products(first: 20) { edges { node { title tags ... on Product { category: tags(first: 1) { edges { node { name } } } } } } } } }
In this example, replace collection-handle with the handle of the collection you want to fetch products from. The tags field returns an array of all the tags assigned to a product, and category is a custom field that uses the tags field to only return the first tag assigned to the product, which would be used as the product’s category.