Filter product in collection by single metaobject fields

Hello,

We are using the collections query to get products and then filter them by their metafields values. Everything was working fine for text fields or metaobject (list) fields but it seems that one of our metafields (a single metaobject) doesn’t support the filtering.
Here is the example of a “productMetafield” filter that we are sending :

{
    "key": "marque",
    "namespace": "meta",
    "value": "gid://shopify/Metaobject/208075915594"
}

The response is a list of products ignoring completely this filter. If we try to combine with another filter on a different field (a metaobject list), the products returned matches our second filter but still ignores the first one.

Has anyone noticed the same behavior ? Is it a limitation or an issue with the storefront API ? (tried with both 2024-01, 2025-01 and 2025-04)

Thanks in advance

Hey @Stephen_Richard :waving_hand: - for collections queries via the Storefront API, we do only support a few different metafield types. There’s a bit more info here, but just referencing this for ease of reference:

Product and variant metafield filters are available for metafields defined using the metafield types single_line_text_field , boolean , numeric_integer , numeric_decimal using API version 2022-04 or higher.

I think this could be what’s happening here - could you let me know if you’re storing the metaobject reference as any of those metafield types? One other thing you mentioned that’s interesting to me is that the metaobject reference list filter seemed to work - would you be able to share the full query you’re making in both instances? I can see if I’m able to replicate exactly on my end and do some digging if needed.

Hope this helps!

Hey @Alan_G ,

After reviewing our queries and payloads nothing seemed off but we noticed that the Marque (or brand in english) metafield was absent from the Search & Discovery module configuration. After adding it (see screenshot), we can filter by all our metafields as expected.

Thank you for your feedback earlier.

Just for reference here is our query and an example of a payload that allow us to combine product filters on metaobject metafields :

query getCollectionProducts($id: ID!, $first: Int, $last: Int, $after: String, $before: String, $filters: [ProductFilter!], $sortKey: ProductCollectionSortKeys, $reverse: Boolean) {
  collection(id: $id) {
    id
    title
    handle
    products(first: $first, last: $last, after: $after, before: $before, filters: $filters, sortKey: $sortKey, reverse: $reverse) {
      edges {
        node {
          id
          title
          vendor
          handle
          marque: metafield(namespace: "meta", key: "marque") {
            value
            key
            id
            reference {
              ...on Metaobject {
                name: field(key: "name") {
                  value
                }
              }
            }
          }
          priceRange {
            minVariantPrice {
              amount
              currencyCode
            }
            maxVariantPrice {
              amount
              currencyCode
            }
          }
        }
      }
      pageInfo {
        hasNextPage
        hasPreviousPage
        startCursor
        endCursor
      }
    }
  }
}
"variables": {
        "id": "gid://shopify/Collection/628561150282",
        "first": 24,
        "last": null,
        "after": null,
        "before": null,
        "filters": [
            {
                "productMetafield": {
                    "key": "marque",
                    "namespace": "meta",
                    "value": "gid://shopify/Metaobject/208074473802"
                }
            },
             {
                "productMetafield": {
                    "key": "regimes",
                    "namespace": "meta",
                    "value": "gid://shopify/Metaobject/207372190026"
                }
            }
        ],
        "sortKey": "COLLECTION_DEFAULT",
        "reverse": false
    }

Hey @Stephen_Richard - glad this helped a little bit at least and thanks for sharing the query (I think that will be super helpful for folks who find this thread in the future (:waving_hand:).

Let me know if we can help out with anything else on our end, I’ll mark this thread as solved :slight_smile: