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

Tomas_Friedrich
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.

Replies 11 (11)
_JB
Shopify Staff
834 99 190

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? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

jkamradcliffe
New Member
3 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.

ClementBR
Shopify Partner
123 2 28

Same here.

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

fran5
Tourist
3 0 3

Is there any news?

This would be extremely useful and a more consistent behaviour.

yaro-shiphawk
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.

Jason
Shopify Expert
10438 168 2081

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.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.
Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.
★ http://freakdesign.com.au ★
fran5
Tourist
3 0 3

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.

andrewbien
Tourist
6 0 8

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

Isaac_Bowen
Shopify Partner
76 0 24

This appears to be working, in my tests - creating a metafield (via the productVariantUpdate GraphQL mutation) is triggering products/update. Can anyone else confirm?

I made Locksmith and Mechanic. :)