sort a collection by availability of product

rabbott
Tourist
3 0 1

Hi, I would like all items in collection that are active to show but those without stock to show at bottom of page, ie sort by availability? The smart collection doesn't work as I have lots of other conditions so have to be by "any condition". Is there a way to do this automatically not manually? Cheers

Replies 9 (9)

PaulNewton
Shopify Partner
6274 573 1318

You will need an app for this type of specific sorting

Usemechanics  has a premade task for that https://tasks.mechanic.dev/move-out-of-stock-products-to-the-end-of-a-collection 

and other automation tasks you can then leveragle https://tasks.mechanic.dev/

 

Merchants that need a mechanic script customized can contact me at paull.newton+shopifyforums@gmail.com

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


RGestwa
Shopify Partner
1 0 0

Curious to know a little more about this, if the collections we're using are manually sorted and we use this premade task to put out of stock items at the bottom of the collection, will the items go back to their original manual sort order when they come back in stock?

 

Thanks,

Mete
Shopify Partner
132 0 37

Hey @RGestwa ,

 

they will if you use our app. https://apps.shopify.com/push-down-hide-out-of-stock

Co-Founder / Developer at: merchbees
Merchbees Low Stock Alert - Keep track of your low stock items by email and slack
Merchbees Inventory Value - Know your inventory value and quantity in real-time
Push Down & Hide Out of Stock - Move out of stock products to the bottom of the collection to improve SEO & hide/ unhide automatically
zimousdigi
Shopify Partner
52 0 2

Hi @RGestwa , yes they will get back to the original position. When you start using the Nada app and turn on sorting on some collections with manual sorting, we save a snapshot of the order and then use it when re-sorting back in-stock products.

Martin Zima
Digismoothie

JozefBalaz
New Member
5 0 0

Hey, you seem like perfect fit for our new application that would go-live in few weeks. 

We are developing an analytics solution with build-in AI machine learning for estimating demand. You can see in our portal not only stock levels for all products/variants but the expected number of days (based on predicted demand in the future) in which products on stock will be completely sold off. 

If you are interested, apply for the private beta here: https://nostradamus.cloud/ 

Try next-generation Business intelligence & AI solution for Shopify

Mete
Shopify Partner
132 0 37

Hi @rabbott,

Our app, Push Down & Hide Out of Stock, does exactly what you want!

You can move out-of-stock products to the bottom of the collection with our app.

It has an easy setup, and all processes are automatic. And also it works in real-time!

If you have any questions, please don't hesitate to reach out to us at support@merchbees.com

Co-Founder / Developer at: merchbees
Merchbees Low Stock Alert - Keep track of your low stock items by email and slack
Merchbees Inventory Value - Know your inventory value and quantity in real-time
Push Down & Hide Out of Stock - Move out of stock products to the bottom of the collection to improve SEO & hide/ unhide automatically

zimousdigi
Shopify Partner
52 0 2

Hi @rabbott 

would you mind checking our app Nada: Sort & Hide Out Of Stock

The app is automatically sorting collections in real-time, so the sold-out products are always at the end of the collection and back when in stock again. You can try it for free to check that it really works smoothly.

Try it for free for 7 days and check if it helps to solve your problem.

Martin

Martin Zima
Digismoothie

bluewill
Shopify Partner
1 0 0

If it's in liquid, after searching for a lot of information, there's really no way to solve it, so we have to use this imperfect solution

{%- liquid
  assign page_size = section.settings.page_size
  assign def_current_offset = 0
  assign def_current_page = 0
  assign def_total_page = 0
  assign loop_min_index = 0
  assign loop_max_index = 0
  assign available_count_page = 0
  assign unavailable_count_all = 0
  assign unavailable_count_page = 0
  assign penultimate_page_available_flag = 0
  assign penultimate_page_available_count = 0
-%}

{% paginate collection.products by page_size %}
  {%- liquid
  assign def_current_offset = paginate.current_offset
  assign def_current_page = paginate.current_page
  assign def_total_page = paginate.pages
  assign loop_min_index = paginate.current_offset
  assign loop_max_index = paginate.current_offset | plus: page_size
-%}
{% endpaginate %}
{% comment %} ----------------------------------------------------Global current page 1-500---------------------------------------------------------------- {% endcomment %}
{%- liquid
    assign current_page = 1
    assign all_product_size = 2000

    if def_current_offset != 0
      assign loop_min_index = loop_min_index | plus: 1
    endif
 -%}
{%- capture available_sort_grid_html -%}

{% comment %} available html {% endcomment %}
{% paginate collection.products by all_product_size %}
  {% for prod in collection.products %}
    {%- liquid 
        if forloop.index <= loop_max_index
            if prod.available
              if forloop.index >= loop_min_index
                  assign available_count_page = available_count_page | plus: 1
                  render 'product-grid-item', product: prod, product_title_wrap: section.settings.product_title_wrap
              endif
            else
              assign loop_max_index = loop_max_index | plus: 1
              assign unavailable_count_all = unavailable_count_all | plus: 1

              if forloop.index >= loop_min_index
                assign unavailable_count_page = unavailable_count_page | plus: 1
              endif

              if def_current_offset != 0 and forloop.index < loop_min_index
                assign loop_min_index = loop_min_index | plus: 1
              endif
            endif
        endif
     -%}
  {% endfor %}
{% endpaginate %}
{%- endcapture -%}

{% comment %} unavailable html {% endcomment %}
{%- capture unavailable_sort_grid_html -%}
    {%- if def_current_page == def_total_page -%}
        {% paginate collection.products by all_product_size %}
            {%- assign tmep_count_unavailale = 0 -%}
            {% for prod in collection.products %}
              {%- liquid 
                  if forloop.index <= loop_max_index
                      unless prod.available
                          assign tmep_count = tmep_count | plus: 1
                          render 'product-grid-item', product: prod, product_title_wrap: section.settings.product_title_wrap
                      endunless
                  endif
              -%}
            {% endfor %}
        {% endpaginate %}
    {%- endif -%}
{%- endcapture -%}

{% comment %} <p>def_current_offset: {{ def_current_offset }}</p>
<p>def_current_page: {{ def_current_page }}</p>
<p>def_total_page: {{ def_total_page }}</p>
<p>loop_min_index: {{ loop_min_index }}</p>
<p>loop_max_index: {{ loop_max_index }}</p>
<p>available_count_page: {{ available_count_page }}</p>
<p>unavailable_count_all: {{ unavailable_count_all }}</p>
<p>unavailable_count_page: {{ unavailable_count_page }}</p>
<p>penultimate_page_available_flag: {{ penultimate_page_available_flag }}</p>
<p>penultimate_page_available_count: {{ penultimate_page_available_count }}</p> {% endcomment %}

{%- assign current_page = def_current_page -%}
{% comment %} -------------------------------------------------------------------------------------------------------------------- {% endcomment %}

 

 

Miriam_Solovey
Shopify Partner
32 0 2

Hi @rabbott this is Miriam from Kimonix app. Our app can help with one click! 

Push your Out Of Stock products to the bottom, of each collection with 1 click. Here’s how it looks in the app:

Miriam_Solovey_1-1706180719563.png

 

You can combine this with more automatic sorting and filtering by more than 60 data points.

Watch this short video to see how easy it is to sort a collection using the app.

Our mission is to bring you the flexibility of a plug-and-play solution (we are not touching your code) together with easily enhancing your merchandising strategy.

Feel free to try the app and let me know if you have any questions! 🤗