Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
I'm trying to query all products in a collection by a metafield value. This seems to be possible with the storefront api according to this page.
https://shopify.dev/api/examples/filter-products#query-products-by-metafield-value
I created a product metafield of true / false type. The following query returns all products, no matter what I put as the value. What am I doing wrong?
query exampleFilteredQuery {
collection(handle: "filterable-collection") {
handle
products(first: 25,
filters: {
productMetafield:{
namespace:"my_namespace",
key:"my_metafield_key",
value:"true"
}
}) {
edges {
node {
id
title
}
}
}
}
}
Solved! Go to the solution
This is an accepted solution.
Apparently I had missed something, so posting it here just in case it helps someone else. Make sure you have done all the following:
1. The products are published to the online store channel.
2. The metafield filter has been added as an available filter under Online store->Navigation->Collection and Search Filters.
3. The metafield types are any of numeric_decimal,numeric_integer,boolean,single_line_text_field.
4. You're using API version 2022-04 or higher.
This is an accepted solution.
Apparently I had missed something, so posting it here just in case it helps someone else. Make sure you have done all the following:
1. The products are published to the online store channel.
2. The metafield filter has been added as an available filter under Online store->Navigation->Collection and Search Filters.
3. The metafield types are any of numeric_decimal,numeric_integer,boolean,single_line_text_field.
4. You're using API version 2022-04 or higher.