1
votes

I am trying to load collection.all_products expression to load all the products of a collection on collections page, but I am experiencing an issue with pagination.

I want to load all the products a collection is containing. So, I am using pagination to set limit on how many product it should load, otherwise it only loads 50 products.

I am using following expression to set pagination product limit:

{% paginate collection.all_products by collection.all_products_count %}

with expectation that collection.all_products should contain all the products.

The expressions works as expected, i.e. returns array of all the products when it is on the first page of the collection, but when I switch to different paginated page of the collection, it returns empty array for all_products.

One thing I noticed is, on paginated page, collection.all_products_count still returns correct number but collection.all_products is empty.

Please, If anyone have faced a similar issue and know a workaround to load all products of a collection on different page, let me know.

Thanks in advance.

PS: I am using Debut theme.

1
Out of curiousity, how many products are in the collection, and what's the pagination_by set to?Dave B
Hello Dave, collection has at max about 250 products. The theme setting is set to paginate at 16 products.Simon.Hermit

1 Answers

3
votes

Is all_products a method of the collection object in the first place? According to Shopify's documentation on collection, the method to call would be collection.products.

https://help.shopify.com/themes/liquid/tags/theme-tags#paginate

May explain why collection.all_products is empty.