Sorting Updated Product Variants by Updated_At

With the changes to allow up to 2000 variants per product, the addition of the variant_gids array (sorted by updated_at according to the docs), and the fact that Shopify sends a products/update webhook for every inventory change without the ability to opt-out of inventory-related changes, are there any plans to also sort the variants in the products/update webhook payload by their updated_at dates?

Many apps and/or companies only care about changes to attributes on the product and variants, and they don’t really care about inventory-related changes. The docs currently make no guarantees about the ordering of the “first 100 variants” on a product with more than 100 variants, but having those variants sorted by updated_at like the variant_gids are would go a long way in helping webhook subscribers cut down on the size and number of follow-up queries they’re forced to make to determine if any relevant changes took place on the attributes of the objects. It would put the “updated” variants in that set of “first 100 variants”, providing an easy way to check incoming payloads against cached values and whatnot.

1 Like

Hi - I’ve flagged this to the Products development team here, and while it’s currently not scheduled to support, it’s definitely something they are considering for future releases.

1 Like

Hey @Liam-Shopify,

Many apps trigger actions based on changes, so we rely on webhooks. With the recent changes, you sort the variant data inside the webhook by variant_id, include only 100 of them, and send a variant_ids array sorted by the updated_at field. This makes it inevitable that we will miss some changes because we queue requests for future fetching due to token limitations. By the time we fetch the data, there could be other updates that have already occurred.

The easiest solution to this problem is to sort the variant data inside product webhooks by the variant’s updated_at field, as suggested by @ktbishop. Alternatively, you could upload the webhook to a resource (similar to bulk operations) so we can fetch the state at that specific moment.

By the way, we care about inventory-related changes in product webhooks, but including the data for the most recently changed variants in the webhook payload would likely benefit everyone.