Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hi,
we have problem with product/update webhook which is not fired after variant's metafield is changed.
webhook is fired after product update, variant update, also after product metafield change, but NOT after variant metafield change or creating new metafield for variant.
We are currecly downloading metafields through API, but it is very slow for many API requests. 1 per product, 1 for product metafields and 1 for each variant metafields.
We want to use product/update webhook with metafields_namespaces setting, but it is useless without fired webhook after variant metafield is changed.
Is it bug or expected behavior? Or is there any other solution?
Thanks for reply.
Hi @Tomas_Friedrich,
I just looked into the webhook not firing on variant metafield change, and I'm not 100% clear on the expected behaviour. Since the webhook fires on changes to the product metafield, I would expect the same behaviour to apply for variants. I'll raise this with our developers to clarify.
In the meantime, I have a few suggestions that should help. Even if you're able to use webhooks, I still suggest using one of these methods to run a job at least once a day to check for anything that may have been missed. Although webhooks are generally reliable, it's possible for a webhook not to deliver in cases of unexpected problems on Shopify's end or yours.
One alternative to the REST API is making your calls using GraphQL. Since GraphQL allows you to specify the individual fields you want in the response, you're able to retrieve a larger data set using few calls. The below call will allow you to retrieve the metafields for 10 products at a time:
{ products(first: 10) { pageInfo { hasNextPage hasPreviousPage } edges { cursor node { id variants(first: 10) { pageInfo { hasNextPage hasPreviousPage } edges { cursor node { id privateMetafields(first: 3) { edges { node { id key namespace value }}}}}}}}}}
The most efficient way to get this data is by using the [BulkOperations API](https://shopify.dev/tutorials/perform-bulk-operations-with-admin-api). This API will allow you to retrieve every variant metafield in a shop using only 2 calls, and the data is delivered in a flat JSONL. It works by taking in a regular graphQL query, with any fields related to pagination removed. Here's an example of a BulkOperation using the example query from above:
mutation { bulkOperationRunQuery( query: """ { products { edges { node { id variants { edges { node { id privateMetafields { edges { node { id key namespace value }}}}}}}}}} """ ) { bulkOperation { id status } userErrors { field message } } }
JB | Solutions Engineer @ Shopify
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Is there any update on this as I'm facing the same issue with products/update webhook not firing when a variant's metafield is changed or created.
Same here.
This issue has been going on for years actually, but it'd be great if this could be fixed
Is there any news?
This would be extremely useful and a more consistent behaviour.
Are there any updates about the issue with products/update webhook not firing when a variant's metafield is changed or created. I've faced with the same problem.
This is expected behaviour so there's nothing to fix.
A metafield is not part of a product or variant - it's an attached resource that sits outside of those objects. So if updated, the product or variant itself doesn't change.
Jason, you completely missed the point.
What's important here is to be able to capture the event of a variant metafield change, no one cares if it the product or variant should change.
Currently, adding or editing product metafields will fire a product/update webhoook (have you read the post?).
OP is asking for a solution, not uninterested replies.
Hi @_JB !
Do you have any update on this? 🙂 I'm having this issue currently on a dev store.
The issue I'm having is that a third party is updating the metafield and I currently have no way of tracking that change. Otherwise your workaround would be fine.
Thanks,
Andrew
Confirmed that this is still not working when the change came from the Admin REST API. 🫤
I also struggled with that issue. products/update webhook didn't fired when creating/updating variant's metafields.
It would be great if this issue will fix soon 🙂
This appears to be working, in my tests - creating a metafield (via the productVariantUpdate GraphQL mutation) is triggering products/update. Can anyone else confirm?
Yes, confirmed, productVariantUpdate GraphQL mutation does trigger a webhook for metafield updates. Also, collectionUpdate does the same