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?
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:
The most efficient way to get this data is by using the BulkOperations 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
}
}
}
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.
This appears to be working, in my tests - creating a metafield (via the productVariantUpdate GraphQL mutation) is triggering products/update. Can anyone else confirm?
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.