How do I get all products of a store and assign it to a variable?

Shopify Partner
2 0 0

I'm trying 

{% for unique_prod in all_products %}
{% endfor %}
But it's printing nothing. Probably because all_products is an object. How do I get all the products of the store (I guess 20 is the limit per page)? Is there something I'm doing wrong?
Reply 1 (1)

Shopify Expert
11196 226 2287

all_products does have a limit of 20 unique handles per page. In this case you're not using it properly as it doesn't return a data set of products like that, but instead returns 1 product based on the handle you feed it.




{{ all_products['some-handle'].title }}


More info in the docs:


It's possible you would want to loop over a collection instead. Still keep in mind that looping over massive amounts of products can lead to performance issues so you can often be better off pulling that data in async.


★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. ★