Shopify collection order guide

How to move sold-out products to the bottom of a Shopify collection

What you’ll need

  • Shopify’s free GraphiQL app (with read_products, write_products access)

    How to get this: Shopify’s free GraphiQL app
    1. Install it once from shopify-graphiql-app.shopifycloud.com: enter your store address, tick the access listed here, click Install and approve.
    2. Then open it any time from Apps › Shopify GraphiQL App in your admin.

    Step-by-step guide (opens in a new tab)

Write the move for my collection

The quick way for a big collection

  1. Type the collection’s handle (the last part of its web address) into the Sold-out to Bottom tool.
  2. Run the read-only query it gives you in Shopify’s GraphiQL app and paste the reply back.
  3. Check the new order, download the undo, then run the move in GraphiQL.
  4. Refresh the collection in your admin: sold-out products are at the end, everything else in the same order as before.

How the move keeps your order

collectionReorderProducts applies moves in the order given, so sending each sold-out product to the last position, one after another, puts them at the end in their original order while every other product keeps its place. It works on manual and automated collections, as long as the collection’s sort is Manually. Shopify keeps no history of a collection’s order, so the only undo is the original order, saved before the move and sent back as moves to positions 0, 1, 2 and so on.

By hand in the admin

  1. Products › Collections › open the collection.
  2. Next to Products, set Sort to Manually.
  3. Drag each sold-out product to the bottom of the list. Shopify saves the order as you go.

It doesn’t stay sorted by itself

A manual order is a snapshot. A product that sells out tomorrow stays where it is, and a restocked product stays at the bottom, until you run the move again. Many shops re-run it once a week, or after a big restock.

For search results Shopify does have a setting: Search & Discovery › Settings › Out of stock products › Show last.

Other ways, and their catch

  • Hide them instead: the condition “Inventory stock is greater than 0” removes sold-out products from automated collections and brings them back on restock. It doesn’t work on manual collections.
  • Apps and Shopify Flow (with a “Send Admin API request” step) can re-sort on a schedule. They cost money or need setup, and Flow has no sort-by-stock action of its own.
  • Skipping sold-out products in the theme’s collection loop leaves gaps, because Shopify splits the pages before your code runs.

Questions

Can Shopify sort collections by inventory automatically?

No. The sort options are Manually, Best selling, Alphabetically, Price, Date and Featured. None look at stock, so sold-out products need moving by hand or with a mutation like the one this tool writes.

Does moving products change my product pages or URLs?

No. Only the position inside that one collection changes. Product pages, URLs, other collections and search are untouched.

More guides