Stop webhooks call for product updates originating from shopify API

Hey @Theau , we are experiencing a similar issue. We have a Lambda function that can update our Shopify products via the API, and we would really like the Product Updates Webhook to not fire if the product is updated this way.
I can see you have outlined the problem thoroughly, and its only been a couple of weeks, but wondering if you’ve found any solutions for this problem.

We are trying to solve this too, and will happily share any progress if we are able to make any.

Hey @dbolesta !
Well not with the help of Shopify unfortunately..
What you can try is, inside your lambda, insert in some redis cache the product id you’re about to update. Then let the Shopify api trigger that webhook anyway but inside that webhook handler read the cache to see if the related product id is the same as the one your lambda inserted earlier. If yes return early and if not process the update.
You can determine some time to live to that cache entry to more or less prevent legit product update made by a user soon after the api made ones. Few seconds should do the trick :))

I’m having the same issue here. Any updates on how did you manage to solve it?

I’m not OP but something you could do is:

  • write a function such as shouldProcessWebhook that takes lastUpdatedAt time from your db and compares it to now. If the time difference is not enough (for example 10 seconds) skip the webhook handling
  • handle the webhook normally and set the lastUpdatedAt to now. If the webhook handler updates the product, it will trigger another webhook but that new webhook will be checked for the lastUpdatedAt time and will fail the shouldProcessWebhook check