Estimates sell-through from inventory drops across runs (orders scope unavailable), accumulating units sold in ctx.store across continuation segments to tag the top N as 'bestseller'.
async def run(ctx): top_n = ctx.params.get("top_n", 10) sold = await ctx.store.get("units_sold", {}) for product in await ctx.shopify.query(ACTIVE_PRODUCTS):
How do you keep a best-sellers collection honest on Shopify?
To keep a best-sellers collection honest on Shopify, this template estimates sell-through by watching inventory drop between runs, accumulates units sold per product, and tags the top performers as bestsellers. Restocks are recognized as inventory going up, not negative sales, so receiving day does not corrupt the ranking. A smart collection bound to the tag then reflects what is actually moving this season, not what moved when someone last curated the list by hand. The size of the set is a parameter: top ten for a boutique, top hundred for a department store.
It is deliberately a proxy: it reads inventory movement rather than order data, and says so, which keeps its permission footprint small for stores that gate order access. The ranking recomputes on every run, and the report shows which products would enter or leave the bestseller set. Review it weekly and the homepage's proof section stops quietly going stale.
Last updated August 24, 2026
If you run a sharper version of this template, or something it inspired, send it in. We review every application and publish the good ones, credited to you or your agency.
AI writes real Python or TypeScript, a dry run rehearses it, you approve, it deploys.
Free plan · no card · 🇪🇺 EU data residency