We are currently working on filtering products based on a metafield in a headless storefront (Hydrogen framework). We followed the documentation to create a basic query for this, but the response doesn’t include the expected metafield value for the products. Here’s the query we used:
query tumbleDryProducts {
collection(handle: "xxxxxxxxxxx") {
id
handle
title
products(first: 10, filters: { productMetafield: { namespace: "custom", key: "flag_name", value: "top" } }) {
nodes {
id
title
metafields(identifiers: [{namespace: "custom", key: "flag_name"}]) {
key
value
}
}
}
}
}
We need products with specific metafield values assigned to them, but the query does not return those filtered products as expected.
Could anyone please provide guidance or fixes for this issue? We’re using the headless storefront built with Hydrogen, and any insights into the correct approach for implementing product filtering based on metafields would be greatly appreciated.
