Collection page custom filter using metafield not working

sumitsharma7667
Shopify Partner
2 0 0

I'm having trouble getting metafields to work with my products on Shopify. I'm on the Basic plan, and I've tried setting up metafields, but they don't seem to be functioning correctly. Can someone help me troubleshoot this issue or provide guidance on how to properly use metafields with products on a Shopify Basic plan?

 

 

Screenshot 2024-05-30 at 10.46.57 AM.pngScreenshot 2024-05-30 at 10.46.44 AM.pngScreenshot 2024-05-30 at 10.46.39 AM.png
query tumbleDryProducts {
  collection(handle: "states") {
    handle
    products(
      first: 10
      filters: {productMetafield: {namespace: "custom", key: "state",      value: "Kerala"}}
    ) {
      edges {
        node {
          id
          title
          metafield(namespace: "custom", key: "state"){
            key
            namespace
            value
          }
        }
      }
    }
  }
}

 

Replies 2 (2)

Eric-HAN
Shopify Partner
53 9 3

Hi, there 

Unfortunately, there is no way to query products by metafield value or any other "custom" field value in admin API.  But I think you could use tags instead.

 

if you use headless in storefront ,This could be correct .  
So my question is you use  the code in storefront or admin Graphql API?

 

- Helpful? Please hit Like and mark it as a solution
- Feel free to contact me iyouandhim@gmail.com
sumitsharma7667
Shopify Partner
2 0 0
Thanks for reply.

@Eric-HAN wrote:

Hi, there 

Unfortunately, there is no way to query products by metafield value or any other "custom" field value in admin API.  But I think you could use tags instead.

 

if you use headless in storefront ,This could be correct .  
So my question is you use  the code in storefront or admin Graphql API?

 




Yes, I am using code for the StoreFront GraphQL API. I'm building my storefront with hydrogen and Remix