我试图在一个页面中显示我网站的所有产品类型,2天后它列出了所有产品类型。
但是现在当该页面加载时会给出错误,例如" shopify液体错误:超出内存限制"
这是我的代码
<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>
我怎样才能克服这个问题?
答案 0 :(得分:1)
尝试以下方法。它更快,更有效率。
<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>