Build a Collection Based on Product Stock at One Location

I’d like to build an automated collection that would pull all products that are available at a specific location. (As in when one manages locations where a product or variant can be pulled from in the product definition.)

Any ideas for doing this automatically? I can’t find where the location is actually associated with a product or variant within the system.

Thanks for any help!

Hey @kallenconsult

Nothing available from the Admin but you could probably wire something together using the Admin API to determine which products are available at a specific location and add them to a collection.

This might be a good starting points: https://shopify.dev/docs/api/storefront/2023-07/queries/locations

You’d need to run the code regularly to keep the collection up to date.

Thanks for the quick response! It does beg another question to this Shopify/liquid novice – is there a way to trigger something like this from within Shopify itself? Like a Cron? Or when we add a new product in the admin interface?

Webhooks might be what you’re looking for :slightly_smiling_face: