Skip to content

Instantly share code, notes, and snippets.

@Maybach91
Last active December 23, 2022 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maybach91/20c1d5a4be1dd245b892b170aee6e91c to your computer and use it in GitHub Desktop.
Save Maybach91/20c1d5a4be1dd245b892b170aee6e91c to your computer and use it in GitHub Desktop.
[Shopify iterate over more than 50 - all collection items] Shopify has a limit to only give 50 items back per collection. So we have to offset the loops till we got all items. #shopify #liquid
{% assign handles = linklists.blogs.links | map:'object' | map:'handle' %}
{% for handle in handles %}
{% assign blog = blogs[handle] %}
{% for article in blog.articles | offset:0 %}
{text:"{{ article.title | escape }}", url:"{{ shop.url }}/{{handle}}/{{ article.handle }}"},
{% endfor %}
{% for article in blog.articles | offset:50 %}
{text:"{{ article.title | escape }}", url:"{{ shop.url }}/{{handle}}/{{ article.handle }}"},
{% endfor %}
{% for article in blog.articles | offset:100 %}
{text:"{{ article.title | escape }}", url:"{{ shop.url }}/{{handle}}/{{ article.handle }}"},
{% endfor %}
{% for article in blog.articles | offset:150 %}
{text:"{{ article.title | escape }}", url:"{{ shop.url }}/{{handle}}/{{ article.handle }}"},
{% endfor %}
{% endfor %}
{% for product in collections.all.products | offset:0 %}
{text:"{{ product.title | escape }}", url:"{{ shop.url }}/products/{{ product.handle }}"},
{% endfor %}
{% for product in collections.all.products | offset:50 %}
{text:"{{ product.title | escape }}", url:"{{ shop.url }}/products/{{ product.handle }}"},
{% endfor %}
{% for product in collections.all.products | offset:100 %}
{text:"{{ product.title | escape }}", url:"{{ shop.url }}/products/{{ product.handle }}"},
{% endfor %}
{% for product in collections.all.products | offset:150 %}
{text:"{{ product.title | escape }}", url:"{{ shop.url }}/products/{{ product.handle }}"},
{% endfor %}
@yoffi-mg
Copy link

With offset it is doesen wort anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment