Paginating a Collection showing variants and products

New Member
2 0 0

In my collection template I'm showing product variants if applicable and products if not. This works very well, safe for the fact that it seems impossible to paginate. I've tried creating a custom array of variants/products, but paginate wants nothing to do with it.

 

Here's the code I'm currently using which works for outputing variants/products in a grid:

{% for product in collection.products %}
       	{% if product.variants.size == 0 %} 
       		{% include 'product-card-grid2', max_height: max_height %}
       	  {% else %}
               {% for variant in product.variants %}
                  {% include 'product-card-grid2', max_height: max_height %}
               {% endfor %}
{% endif %}

How do you paginate something like this? Essentially I'd like something like the excellent pimoroni.com, but being a programmer I'm not willing to pay for a plugin :o)

 

Liquid seems exceptionally rigid in terms of array construction/manipulation

0 Likes
Highlighted
New Member
2 0 0

So this took a while and much cussing about Liquid's limited functionality, but here it is: https://stackoverflow.com/questions/57289338/paginating-variant-collection-in-liquid/57296244

0 Likes