Ad

How Do I Loop Through All The Products Of A Store Using Liquid (Shopify)?

- 1 answer

I can't. I know.

Shopify imposes a limit when it comes to the number of products one can loop through on a page.

The current limit is 50.

Actually, this is not true.

One can loop through all the products of a store using liquid :

{% paginate collections["all-products"].products by 10000 %}

  {% for product in collections["all-products"].products %}

     {% comment %}looping through all 10000 products{% endcomment %}

  {% endfor %}

{% endpaginate %}

In the above example, if a store has up to 10000 products I can loop through all 10000 of them. Increasing that pagination number will increase the number of products I can loop through accordingly.

What I want to know is whether Shopify will continue to support this (even though they don't like it) and therefore, whether I can build stores using the above without the risk of the {% paginate collections["all-products"].products by 9999999 %} becoming deprecated at some point.

Having said that, I would obviously never loop through 10000 products, let alone 9999999 of them. But I definitely want to build stores where I will be looping through more that 500 products in one go for example.

Ad

Answer

pagination limit is maxed out at 1000. Beyond that it'll either stop at 1000 or give a liquid error. I have had the same issue earlier.

Ad
source: stackoverflow.com
Ad