简体   繁体   English

使用Liquid获取通过标签过滤的所有shopify产品

[英]Get all shopify products filtered by a Tag using Liquid

Is it possible to query all products in shopify by a tag (or set of tags) using Liquid. 是否可以使用Liquid通过标签(或标签集)查询shopify中的所有产品。

I thought I had it by looping through collections.all.products and then filtering in the loop but then realised that the collection was limited to a page size of 50. 我以为我可以通过遍历collections.all.products然后在循环中进行过滤来实现,但是后来意识到该集合被限制为50页大小。

If it meant to be displayed in frontend, Shopify does not support the paginate hack quoted by Hymnz above. 如果要在前端显示,则Shopify不支持以上Hymnz引用的分页hack。

However, even if query is limited to 50 products, you may clearly make your query and then use pagination.Something like this may work to filter products list: 但是,即使查询仅限于50种产品,您也可以清楚地进行查询,然后使用分页。类似的方法可能会过滤产品列表:

{% for product in collections.all.products %}
{% if product.tags contains 'mytag' %}
Do something
{% endif %}
{% endfor %}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM