Webhook product/update not fired after variant's metafield is changed

Highlighted
Shopify Partner
2 0 1

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.

1 Like
Highlighted
Shopify Staff
Shopify Staff
520 64 115

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 | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

2 Likes
Highlighted
New Member
1 0 0

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.

0 Likes
Highlighted
Shopify Partner
92 2 12

Same here.

This issue has been going on for years actually, but it'd be great if this could be fixed

1 Like
Highlighted
Tourist
3 0 1

Is there any news?

This would be extremely useful and a more consistent behaviour.

0 Likes
Highlighted
New Member
1 0 0

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.

0 Likes
Highlighted
Shopify Expert
9887 101 1731

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.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Tourist
3 0 1

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.

0 Likes
Highlighted
Tourist
5 0 4

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

0 Likes