Ad

Shopify Liquid Error: Memory Limits Exceeded

- 1 answer

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 target="_blank" rel="nofollow noreferrer" href="/collections/{{ product_type | handleize }}">{{ product_type }}</a></li>
     {% endif %}
     {% endfor %}
     </ul>
     </div>

how can i overcome this problem ?

Ad

Answer

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 target="_blank" rel="nofollow noreferrer" href="/collections/{{ collection.handle }}">{{ product_type }}</a></li>
    {% endif %}

    {% endfor %}
    </ul>
</div>
Ad
source: stackoverflow.com
Ad