Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I loop through all the products of a store using Liquid (Shopify)?

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.

like image 852
Sprout Coder Avatar asked Sep 26 '22 12:09

Sprout Coder


1 Answers

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.

like image 165
HymnZzy Avatar answered Oct 12 '22 12:10

HymnZzy