0
votes

I was trying to display all the product types of my site in one page , 2 days back it was listing all the all the product type.

But now when that page is loads its giving error like "shopify Liquid error: Memory limits exceeded"

Here is my code

<div class="rte">
     {{ page.content }}
   <ul class="vendor-list block-grid three-up mobile one-up">
     {% for product_type in shop.types %}
     {% assign its_a_match = false %}

     {% capture my_collection_handle %} {{ type | handleize | strip | escape  }}       {% endcapture %}
     {% assign my_collection_handle_stripped = my_collection_handle | strip | escape %}

     {% for collection in collections %}
     {% if my_collection_handle_stripped == collection.handle %}
     {% assign its_a_match = true %}
     {% endif %}
     {% endfor %}

     {% if its_a_match %} 
    <li class="vendor-list-item"><a href="/collections/{{ product_type | handleize }}">{{ product_type }}</a></li>
     {% endif %}
     {% endfor %}
     </ul>
     </div>

how can i overcome this problem ?

1
Shopify server can render only 40000 items in a single forloop. Either they are nested inside each other doesn't matter. Try a different logic for your requirement.HymnZzy
i don't have more than 40000 items . i have only unique 2000 items . @HymnZTrend Snaps
For each product_type, all the collections are being cycled; shop.types * collections can result 40000. Check math and let me know.HymnZzy
Also what is type in {{ type | handleize | strip | escape }}? Do you mean product_type?HymnZzy

1 Answers

1
votes

Try the following. It's faster and more efficient.

<div class="rte">
    {{ page.content }}
    <ul class="vendor-list block-grid three-up mobile one-up">
    {% for product_type in shop.types %}

    {% assign type = product_type | strip | escape | handleize %}

    {% assign collection = collections[type] %}

    {% if collection.handle != '' %}
        <li class="vendor-list-item"><a href="/collections/{{ collection.handle }}">{{ product_type }}</a></li>
    {% endif %}

    {% endfor %}
    </ul>
</div>