Collection limit pagination

borislav_tsonev
New Member
1 0 0

Hi, i'm trying to write a code that has to show images of related by tag products in my product page.

I'm working on a theme that's called Minimal !

My biggest problem is the fact that my collections are big and i can't get all products that i have to compare and see if they have the tag that i am looking for and to show there image on the page.

I'm trying to paginate it, but it that's the error tha gives me : Liquid error (sections/product-template.liquid line 394): Array 'collections.all.products'' is not paginateable.

I tried to change the collection to see if it is from it but it still gives the same mistake.

That's my code so far:

 

{% for tag in product.tags %}
{% if tag contains "_alt_" %}
{% assign myTagForSearching = tag %}
{% unless collections.all.products == blank %}
<fieldset style="margin-top:5px">
<legend style="margin-top:10px;font-weight: normal;font-size: 17px;font-weight: bold;">Other colors:</legend>
<div class="color-variants">
<ul>

{% paginate collections.all.products by limit %}
{% for productRelated in collections.all.products %}

{% for tagRelated in productRelated.tags %}

{% if tagRelated contains myTagForSearching %}

{% assign productRelatedVariantsIndex = '' %}

{% for variantRelated in productRelated.variants %}
{% if variantRelated.available %}
{% assign productRelatedVariantsIndex = productRelatedVariantsIndex | append: 'x' %}
{% endif %}
{% endfor %}

{% if productRelatedVariantsIndex != '' %}

<li><a href="{{ productRelated.url | within: collection }}" title="{{ productRelated.title }}"><img src="{{ productRelated.featured_image | img_url: 'medium', crop: 'center', format: 'pjpg' }}" height="48px" alt="{{ productRelated.title }}"></a></li>

{% else %}

<li>
<a href="{{ productRelated.url | within: collection }}" title="{{ productRelated.title }}"><img src="{{ productRelated.featured_image | img_url: 'medium', crop: 'center', format: 'pjpg' }}" height="48px" alt="{{ productRelated.title }}"></a>
<img src="https://cdn.shopify.com/s/files/1/0454/5150/9912/files/gie5B478T_751b0cfb-a98b-4ec2-b2d4-eb3f8814782..." style="margin:2.5% 5% 2.5% 5%" width="90%" height="90%" class="out_of_stock_color"/>
</li>

{% endif %}

{% endif %}
{% break %}
{% endfor %}

{% endfor %}
{% endpaginate %}
</ul>
</div>
</fieldset>
{% endunless %}
{% break %}
{% endif %}
{% endfor %}

Reply 1 (1)
ChoosiZon
Navigator
372 61 95

What i see is you paginate collection products in product-template.liquid 

It should be in collection.liquid or something similar.

For faster response with a fee pls email to : choositech@outlook.com ------ Donate