skip to Main Content

I need to syncrhonize another store on the Shopify products.
I need to keep synchronized content (including pictures), inventory and price.

To do so I’m using the products/update webhook.
When a product is updated I resynchronize the whole product on the other store.

Problem is, when I receive the webhook object it doesn’t contain any information about what has changed.

So for example if I have a product with 20 variants and I update 20 prices I synchronise 20 times all the variants because the API doesn’t tell me which field has changed or which variant was modified.

Is there any way to know what has changed? I could compare the data on the other store, but in practice it is more complicated than just overwrite (think about the pictures…).

There is no field "last edit" on the variant so I cannot check that, to see if it’s recent.

2

Answers


  1. Chosen as BEST ANSWER

    There is no actual solution for this. The solution I'm using is to throttle.

    When I receive a product/update hook I save the variant ids on a table (where the variant_id is unique).

    On a separate process, every few minutes I process all (actually some) variant ids in the table. This way if a variant_id is repeated I process it only once every few minutes.

    This won't avoid processing unedited variants, but I couldn't find any way to discard those.


  2. The answer I provide you is stunningly simple, and the one I use in production all the time. Take it, run with it, and I hope it serves you as well as it serves me.

    When you receive a webhook of a freshly updated product, it is true you get no diff or report on what changed. But, it is trivial to remove all ID keys from the product object with a simple function. Now, the result of that, is a naked product, all the details, but none of the identification. So it is prime!

    Now open an API session on your other store, and do a product update call using the handle to match the other product, and provide the newly ID-less object as your data.

    The result is a perfect update in the other store, and you did next to nothing!

    Try it. You might like it!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search