{% paginate collections.collectionname.products by 1000 %}
{% for product in collections.collectionname.products %}
{{ forloop.index }}
{% endfor %}
{% endpaginate %}
However, even though I’m paginating by 1000, only 250 products are actually being iterated over — I verified this using {{ forloop.index }} for debugging.
I need to be able to loop through all products in the collection to show users all relevant results.
Is there any workaround or trick to access the entire collection, maybe by looping through all pages or using another approach?
There is a limit on pagination size. Initially it was 50, then it was changed to the higher value, but there is a reason for the limit – performance, both from on the storefront and server side.
Looping over all collection products, especially when there are more than 250 of them will take quite some time and delay rendering your page.
There was always an option to use {% layout none %} and fetch this data with Ajax – in this case maximum pagination size was significantly higher.
Have you considered other approaches – not sure what your goal is, but maybe using search and filtering can help here?