I want to get all the sold out items to be moved to the back of the collection page, struggle to get the code to work for myself. Does anyone have a solution for this?
Hi @Ksoldier
To move all sold-out items to the back of collection pages in the Minimog theme, there is no built-in Shopify or Minimog setting that automatically reorders products by stock status. However, you have a few practical options based on community solutions and Shopify theme customization principles:
1. Manual Sorting in Shopify Collections (Simplest but Manual)- Go to Products > Collections in your Shopify admin.
- Open the desired collection.
- Set the Sort option to Manually.
- Drag and drop sold-out products to the bottom of the product list.
- This keeps sold-out products visible but at the end of the collection.
This method is straightforward but requires ongoing manual updates as inventory changes.
2. Custom Liquid Code to Sort Products by Availability (Technical, Limited by Shopify Pagination)You can modify your collection template code to reorder products so that in-stock items appear first and sold-out items last. A common approach is:
{% assign in_stock_products = collection.products | where: "available", true %}
{% assign out_of_stock_products = collection.products | where: "available", false %}
{% assign sorted_products = in_stock_products | concat: out_of_stock_products %}
{% for product in sorted_products %}
{{ product.title }}
{% endfor %}
Important caveats:- This method works on the full collection array but breaks Shopify’s native pagination because collection.products is a paginated object, while sorted_products is a new array without pagination.
- To work around this, you can increase the pagination limit to a very high number (e.g., 1000) to show all products on one page, but this can impact page load speed and user experience.
- Adjust the code to fit Minimog’s collection template structure, typically found in sections**/collection-template.liquid** or similar.
This approach requires some Liquid coding skills and testing.
3. Use a Shopify App for Automated SortingSeveral apps automate pushing sold-out products to the end of collections and dynamically update as inventory changes:
- Merchbees Push Down & Hide Out of Stock: Automatically moves out-of-stock products to the bottom and restores them when back in stock, with easy setup and no code required.
- Nada - Sort & Hide Out of Stock: Real-time sorting of collections to push sold-out items last.
- Custom Collections Builder: Allows sorting collections by stock quantity and other criteria.
Apps provide a hassle-free, automated solution especially if you have many collections or large inventories.