Move sold-out products to the bottom of a Shopify collection
Shopify can’t sort a collection by stock, so sold-out products sit among the ones people can buy. Enter a collection, run one read-only query in Shopify’s GraphiQL app, and this page writes the move that puts every sold-out product at the end while the rest keep their order. It also writes the undo.
What you’ll need
Shopify’s free GraphiQL app (with read_products, write_products access)
How to get this: Shopify’s free GraphiQL app
- Install it once from shopify-graphiql-app.shopifycloud.com: enter your store address, tick the access listed here, click Install and approve.
- Then open it any time from Apps › Shopify GraphiQL App in your admin.
1Choose the collection
The last part of the collection’s address: summer-sale from yourstore.com/collections/summer-sale. The admin address with its number works too.
“No variant can be bought” matches Shopify’s Sold out badge and leaves pre-order products (Continue selling when out of stock) where they are. “Total inventory” moves them down too.
2Read its current order
Run this in the GraphiQL app. It only reads. Install the app once from Shopify’s GraphiQL app setup with read_products and write_products.
# Easy Store Tools: read one collection's order (read-only)
query SoldOutToBottom {
collection: collectionByIdentifier(identifier: { handle: "your-collection-handle" }) {
id
title
handle
sortOrder
ruleSet { appliedDisjunctively }
productsCount { count }
products(first: 250, sortKey: COLLECTION_DEFAULT) {
pageInfo { hasNextPage endCursor }
nodes {
id
title
totalInventory
tracksInventory
variants(first: 100) { nodes { availableForSale } }
}
}
}
}3Check and move
The new order, the move and its undo appear here after you read the reply.
How it works
- Enter the collection’s handle and pick what counts as sold out.
- Run the read-only query in the GraphiQL app and paste the reply. Collections over 250 products are read in pages.
- Check the new order, download the undo, then run the move (250 products per part).
- Re-run it whenever stock changes; for search, set Search & Discovery › Out of stock products to Show last.
Guides
Questions
Can Shopify put sold-out products last automatically?
Not in collections. Shopify’s collection sorts (best selling, price, date, alphabetical) ignore stock. Only search has a “show last” setting, in Search & Discovery. For collections you set Sort to Manually and move the products, which this tool does in one step.
Do I have to run it again?
Yes, when stock changes. A manual order is a snapshot: products that sell out later stay where they are, and restocked products stay at the bottom, until you run it again. Re-running takes about a minute.
What counts as sold out?
By default, a product none of whose variants can be bought (Shopify’s own availableForSale, so pre-order products with Continue selling stay up). You can switch to “total inventory 0 or less” to move pre-order products down too.
Will it change the order of my other products?
No. Products with stock keep the order they had; only sold-out products move, and they keep their order among themselves at the end. The undo puts every product back where it was.
Is anything uploaded?
No. The page builds the GraphQL in your browser. You run it yourself in Shopify’s GraphiQL app, so we never see your store.
Based on collectionReorderProducts (Shopify GraphQL Admin API) and Changing a collection’s sort order (Shopify Help Center).
Related: Hide Sold Out · Sold Out Diagnoser · Collections Bulk Builder