[Feature Request] Filtering products based on existance of specific metafield namespace and key

It would be great to have the capability to filter (query) products based on the existence of a specific metafield key.

In my app I am adding specific metafield key to products and later I want to fetch products which doesn’t have or have this metafield. So users can see products which are not configured.

I know filtering based on value is technically very complex problem so this is not what I am asking. But I guess filtering based on metafield key existence on the product should be possible.

So basically let say fetching all products with metafied “craftshift.variant_images”

Hey Farid,

From looking into this, it doesn’t seem like there’s an easy way to do this. It looks like you’d need to use the products query to fetch products in batches and then checking each product’s metafields programmatically to identify those with the desired key. I’ve also connected with our internal team to see what they’d recommend.

1 Like

Thanks Liam, I am sure this will be super helpful feature for every app that is adding metafields to resources such as products, variants, orders etc.

I have found this documentation : Query by metafield value

The documentation mentioned that we can filter products with metafield value exact match, perhaps you can query something like “craftshift.variant_images = true” if exact match is possible.

Hope this can help!

1 Like

Thanks Axel :pray: This looks like almost what I need but is not what exactly I need. Will play with it to see maybe I can make it work for my case.

I actually ended up creating an additional metafield definition and use it as an indexing to check whether configuration exists and this approach made possible to implement this feature. Thanks again @soulchild for the solution.

1 Like