I’ve been poking at understanding inventory update performance through Flow, and can’t seem to get productVariant.inventoryItem.updatedAt to change for a given variant.
What will cause it to update? Changing price, inventory quantities or other fields doesn’t seem to update the field.
Or, I may be mis-understanding the field function. Help?
Thanks!
Here’s what I’m logging from a Product variant inventory quantity changed trigger.
{%- assign now_time_epoch = 'now' | date: "%s" -%}
{%- assign update_time_epoch = productVariant.inventoryItem.updatedAt | date: "%s" -%}
{%- assign elapsed_time = now_time_epoch | minus: update_time_epoch -%}
{%- assign time_message = "" -%}
{%- if elapsed_time > 3600 -%}
{%- assign time_difference = elapsed_time | divided_by: 3600 -%}
{%- assign time_message = " (" | append: time_difference | append: " hours!)" -%}
{%- endif -%}
Inventory has changed.
Product variant SKU: {{ productVariant.sku }}
Product variant: {{ productVariant.id }}
Variant item ID: {{ productVariant.inventoryItem.id }}
Variant inventory update time: {{ productVariant.inventoryItem.updatedAt }}
Log time: {{ 'now' | date: "%Y-%m-%dT%H:%M:%S" }}
Update/log difference : {{ elapsed_time }} seconds{{ time_message }}
Prior inventory quantity: {{ inventoryQuantityPrior }}
New inventory quantity: {{ productVariant.inventoryQuantity }}
And the output:
Inventory has changed.
Product variant SKU: test-product
Product variant: gid://shopify/ProductVariant/50162399412544
Variant item ID: gid://shopify/InventoryItem/51817452831040
Variant inventory update time: 2025-01-15T15:34:22Z
Log time: 2025-01-17T03:37:58
Update/log difference : 129816 seconds (36 hours!)
Prior inventory quantity: 3
New inventory quantity: 4