Overcome limit of 50 in for loop in shopify

一曲冷凌霜 提交于 2020-01-02 04:36:18

问题


I have paginated a product list over a limit of 50 to fit in the whole page (index.liquid). But the if condition within for loop doesn't apply over whole paginated items as for loop is limited to 50 items. Any help would be appreciated.

 <td class="collection-reviews">
       {% paginate collections.all.products by 1000 %}


        {% for product in collections.all.products %}
        {%if product.metafields.spr.reviews %}
         <div id="shopify-product-reviews" data-id="{{product.id}}">{{  product.metafields.spr.reviews }}</div>
        {%endif%}
        {% endfor %}
         {%endpaginate%}
      </td>

回答1:


No, you cannot overcome it, You can query up to 50 product per page, Shopify won't allow more than 50 products, in order to maintain server load balance.

quote from shopify documentation : http://docs.shopify.com/manual/configuration/store-customization/page-specific/collections/add-view-all-to-collection-pages

Don't ever paginate a collection by more than 50, that's how many products maximum you should query per page. Be respectful of Shopify's app servers. If you are not using any paginate tags, pagination does kick in behind the scene and you will only receive the first 50 products in said collection.



来源:https://stackoverflow.com/questions/26807967/overcome-limit-of-50-in-for-loop-in-shopify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!