Filter products by metafields using comparison operators

Hi,

I’m developing a headless store with Shopify and I finally managed to filter my products by price, vendor and by metafield.

But one of my metafields is an integer and I would like to filter products with this metafield value lower than X or greater than X.

In the documentation, there is only an example for filtering products with metafield value = X, so is there a way to do it?

Can I use a key “max” or “min” like prices?

[
        'productMetafield' => 
            [
                'namespace' => 'custom',
                'key' => 'length',
                'value' => 18
            ]
        ]
[
        'productMetafield' => 
            [
                'namespace' => 'custom',
                'key' => 'length',
                'max' => 18
            ]
        ]

Hi @Antoine054 :waving_hand:

At this time, only the below 4 metafield types are supported for filtering on the storefront. The price filter has min/max parameters because it is a range type. It would certainly be valuable to filter by range parameters, and I’ll be sure to let our product team know for future consideration.

  • number_integer
  • number_decimal
  • single_line_text_field
  • boolean

Hope that helps!

Hi,

Thank you for your reply. That’s what I thought, I really hope this will be taken into consideration as it’s much needed right now!

1 Like