{% for collection in collections %}
{% for product in collections.collection.handle.products %}
{{ product.name }}
{% endfor %}
{% endfor %} 我正在Shopify中构建显示所有产品的模板,我使用cheat sheet示例来获得所有产品,但它的工作方式是这样的。
这在我的liquid页面中不起作用,我使用另一种方法来获取集合名称,并显示此集合的所有产品。一个循环是获取集合名称,一个是获取与该集合相关的产品列表。
发布于 2020-09-29 02:36:36
有一个名为" all“的集合,其中包含您所有的产品。它是自动创建,当您创建具有相同名称/url的"all“集合时,它可以被覆盖。
More Infor here on the All collection
{% for product in collections.all.products %}
{{ product.name }}
{% endfor %}发布于 2021-04-23 22:24:04
对于Shopify集合和产品中的嵌套循环,请使用以下方法:
{% for collection in collections %}
{{ collection.title }}
{% for product in collection.products %}
{{ product.title }}
{% endfor %}
{% endfor %}使用此功能,您可以获得集合的所有详细信息,并列出此集合的所有产品。这段代码工作正常,目前在我的商店中也使用了这段代码。
https://stackoverflow.com/questions/64059423
复制相似问题