What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Access metafields from a sales channel app

Access metafields from a sales channel app

edweis
Shopify Partner
16 0 4

I have a sales channel and I want to read the metafield definitions or the metafield values of product listings.

 

Tentative 1: get metafield definitions

I tried to send the following GraphQl request:

 {"query":"query ($owner: MetafieldOwnerType!) { metafieldDefinitions( ownerType: $owner, first:1) { edges { node { id key name description validations { name type value} type { name} } } } }","variables":{"owner":"PRODUCT"}}

  that fails with a 500:

 

{
	"errors": [
		{
			"message": "Internal error. Looks like something went wrong on our end.\nRequest ID: 121144ea-3934-4978-ae66-9b31fb10d467-1715066226 (include this in support requests).",
			"extensions": {
				"code": "INTERNAL_SERVER_ERROR",
				"requestId": "121144ea-3934-4978-ae66-9b31fb10d467-1715066226"
			}
		}
	]
}

Doing some research I found it can be a permission issue. note that the app has the permission read_product_listings.

 

Tentative 2: get the product listing

By querying the REST API product_listings, we do not get the meta field values

 

 

 

How can I get the product's metafields from my sales channel?

 

Thank you

Reply 1 (1)

edweis
Shopify Partner
16 0 4

I am still interested in this feature. We found a workaround to list all metafields from prodcut_listing bunt it requires a lot of API calls to Shopify.