【问题标题】:shopify Liquid error: Memory limits exceededshopify Liquid 错误:超出内存限制
【发布时间】:2016-11-14 06:15:55
【问题描述】:

我试图在一页中显示我网站的所有产品类型,2 天前它列出了所有产品类型。

但是现在当该页面加载时,它会出现 "shopify Liquid 错误:超出内存限制"

之类的错误

这是我的代码

<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>

我该如何克服这个问题?

【问题讨论】:

  • Shopify 服务器只能在单个 forloop 中呈现 40000 件商品。它们是否嵌套在彼此内部都没关系。根据您的要求尝试不同的逻辑。
  • 我没有超过 40000 个项目。我只有独特的 2000 件物品。 @HymnZ
  • 对于每个product_type,所有的集合都在循环; shop.types * collections 可以得到 40000。检查数学并告诉我。
  • 还有{{ type | handleize | strip | escape }}中的type是什么?你的意思是product_type?

标签: shopify liquid liquid-layout


【解决方案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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多