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

Tomas_Friedrich
Shopify Partner
3 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 12 (12)

_JB
Shopify Staff
836 100 223

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

jkamradcliffe
Shopify Partner
3 0 2

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
158 2 46

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 4

Is there any news?

This would be extremely useful and a more consistent behaviour.

yaro-shiphawk
Visitor
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
11196 226 2287

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 in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
fran5
Tourist
3 0 4

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.

Andrew-W
Shopify Partner
27 3 14

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

simonhaenisch
Shopify Partner
16 1 36

Confirmed that this is still not working when the change came from the Admin REST API. 🫤

FlashSearch
Shopify Partner
10 0 9

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 🙂

Flash Search - AI-powered Search & Filter, Merchandising, Analytics, Support OS 2.
Isaac_Bowen
Shopify Partner
77 0 25

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. 🙂
OleACF
Shopify Partner
5 0 5

Yes, confirmed, productVariantUpdate GraphQL mutation does trigger a webhook for metafield updates. Also, collectionUpdate does the same

Accentuate Custom Fields | Undo