2017-03-29 33 views
0

我有在它超過150篇Shopify博客獲得50餘篇

{% assign countItem = 0 %} 
{% for article in blogs.recipes.articles %} 
    {% if countItem < 3 %} 
     {% if article.tags contains product.title %} 
     {% assign countItem = countItem | plus: 1 %} 
     <li class="article"> 
      <a href="{{ article.url }}"> 
       <img src="{{ article | img_url: 'grande' }}" alt="{{ article.title }}" /> 
       <span class="title">{{ article.title }}</span> 
      </a> 
     </li> 
     {% endif %} 
    {% endif %} 
{% endfor %} 

然而blogs.recipes.articles只返回50

任何方式消除這種限制的shopify博客?

回答

1

Shopify將結果限制爲50以平衡服務器負載。根據shopify文檔。

永遠不要將一個集合分頁超過50個,這就是每頁最多可以查詢多少個產品。尊重Shopify的應用服務器。如果您沒有使用任何分頁標籤,則分頁確實會在場景後面進行,您將只收到該集合中的前50個產品。

但是我試圖通過使用paginate標籤來加載50多個產品。但是,這會減慢頁面加載速度,並且如果記錄數很大,該頁面可能會變得無響應。你可以嘗試如下: -

{% paginate blogs.recipes.articles by 500 %} 
{% assign countItem = 0 %} 
{% for article in blogs.recipes.articles %} 
{% if countItem < 3 %} 
    {% if article.tags contains product.title %} 
    {% assign countItem = countItem | plus: 1 %} 
    <li class="article"> 
     <a href="{{ article.url }}"> 
      <img src="{{ article | img_url: 'grande' }}" alt="{{ article.title }}" /> 
      <span class="title">{{ article.title }}</span> 
     </a> 
    </li> 
    {% endif %} 
{% endif %} 
{% endfor %} 
{% endpaginate %} 
+0

工作,謝謝你的時間 – zanderwar

相關問題