Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
I'm trying to fetch product meta fields via. Storefront API for one collection.
API doesn't return any error, but edges property has an empty error.
I tested if the product has meta fields via. Admin API and I'm sure that yes.
My query:
query { shop { collectionByHandle(handle: "xxx") { id products(first: 250) { edges { node { id handle title description metafields(first: 100) { edges { node { key value } } } } } } } } }
Hi @airShopify ,
In order to fetch Product Metafields via the Storefront API, you need to first use the Admin API to expose the metafield and make it visible. Once the metafield is visible to the Storefront API, you're able to query for it with the query you posted above.
Read this document for more details: https://shopify.dev/tutorials/retrieve-metafields-with-storefront-api
To learn more visit the Shopify Help Center or the Community Blog.