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

蓝咒 提交于 2020-12-01 12:08:42

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/35105718/how-do-i-loop-through-all-the-products-of-a-store-using-liquid-shopify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!