Handle out-of-stock items without hurting your store!
Keep your customer experience seamless and your SEO intact by managing sold-out products the smart way. Learn how to move them to the bottom of your collections and keep your storefront clean, efficient, and conversion-ready.
Handle out-of-stock items without hurting your store!
As a Shopify merchant, providing a clear and enjoyable browsing experience for your visitors is essential.
There's nothing more frustrating for a customer than browsing a collection and coming across a series of out-of-stock products before even seeing the items they can actually purchase.
So, how can you ensure that out-of-stock products are automatically pushed to the bottom of your collections without negatively affecting your Shopify store’s performance or complicating your daily management?
Best practices for managing out-of-stock products
Before attempting to sort out-of-stock products in your collections, it's essential to establish good management practices.
A poor strategy for out-of-stock products can degrade the customer experience and negatively affect your SEO.
These should be handled differently, both in terms of user experience and SEO.
For products that are permanently out of stock: redirect wisely
It’s essential not to leave the page of a permanently out-of-stock product inactive, as it could negatively impact both navigationand SEO if it remains indexed without serving a purpose.
Rather than deleting it (which might create 404 errors), and if this URL generates significant traffic, set up a 301 redirect to a relevant page:
To a similar product: maintains the customer's purchase intent
To an associated collection: ideal if no equivalent product is available, offering alternative option
To the homepage (last resort): avoid this if possible, as it makes little sense for the user unless there’s no other relevant alternative
These redirects ensure a smooth transition for the user while preserving the SEO value of the out-of-stock product page.
For temporarily out-of-stock products: don’t delete the page
Removing out-of-stock products can hurt SEO (404 errors, lost rankings/backlinks) and damage customer experience if the page was bookmarked or found via Google.
Instead, keep the product page live, display a clear "out of stock" message, and suggest alternatives like back-in-stock alerts or similar items.
Placing out-of-stock products at the end of collections improves navigation and highlights available items. It keeps the shopping experience smooth and focused on what’s actually for sale.
However, Shopify doesn’t offer automatic sorting by stock status. Manual sorting is possible, but it’s time-consuming—especially with large catalogs and frequent inventory updates.
It’s still possible to achieve this result through several different approaches:
Push out-of-stock items to the bottom of your collections
1. Customizing the theme's liquid code
You can modify your theme’s Liquid code. This approach allows you to adjust the display order of products directly within your collections. Here's how to proceed:
Access your theme’s code
Modify the product loop in the collection file:
Find the file that generates the collection (usually collection.liquid or collection-template.liquid)
Identify the loop {% for product in collection.products %}
Add a condition to prioritize in-stock products first:
(Note that this modification depends on the structure of your theme.)
The products will only be sorted on the current page. Shopify’s collection.products is paginated (e.g., 24 products per page) before any filters or sorting can be applied. Therefore, this filter will only apply to products visible on that page.
To force out-of-stock products to appear at the bottom of the collection, you could consider removing pagination and loading all products on a single page. This can be achieved by increasing the page size with a directive like {% paginate collection.products by 1000 %}.
However, this approach has drawbacks:
Slower loading speeds
1000 products/page limit
Bad user experience for large inventories
2. Using Shopify API for dynamic sorting of collections
If you have access to a Shopify developer, you can use the API to retrieve the list of products in a collection and sort them before displaying them. To do this:
Retrieve data: Use Shopify’s API to fetch the product data from a collection.
Sort products: Apply sorting on the front end to display in-stock products first, followed by out-of-stock ones.
Integrate into your store: Use a JavaScript script to integrate this sorting into your store.
Unlike the previous method, this approach allows you to sort all products, not just those visible on the current page. This ensures a smooth navigation experience regardless of your stock volume.
However:
Needs Liquid development expertise
Risk of performance degradation (possible loading delays)
For merchants who prefer simple, intuitive, and visual management, using a specialized app remains a more comfortable long-term solution.
Using Visual Merchandiser
If you prefer not to code or manage sorting manually, Visual Merchandiser lets you easily sort your collections by stock quantity directly from an interface that reflects the layout of your store.
"The Visual Merchandiser app is really great! It saves us a lot of time organizing our large categories with efficient filters and multiple criteria (especially the descending stock sorting). This is exactly what we were looking for since our Shopify redesign, and it perfectly meets our needs. Super practical, I recommend it!"