Notify store owner when products of a collection are all sold out

Hi,

I have a doubt on how to structure a workflow that sends an email to the store owner if all products of a collection are sold out (and if that’s possible)

I thought about using the variant out of stock trigger but I couldn’t find out how to query the collections that specific product belongs to. Another option would be to have a manual trigger that checks all collections and inventory, but the store has 6000 products and 250 collections so it might take a long time.

You can query smart collections a product belongs to using the product_id filter:

https://shopify.dev/docs/api/admin-rest/2024-01/resources/smartcollection#get-smart-collections?since-id=482865238

But I have a feeling this use case might be tricky to accomplish with flow. I don’t think you can get more than 100 products at a time.

Yes, largest collection has 900 products so it would take a while.

Do you know how else I would be able to do this if not with Flow?

I started putting together a workflow for this but hit a couple of snags. One’s an internal API error that comes up sometimes randomly - I’d be curious to see whether it happens for your store or it’s just happening in my dev store.

The other is that the query works a little weird when you have multiple locations. How many locations do you have?