捕获Shopify收藏中的所有产品
当我在Shopify中循环浏览一个集合时,我想将该产品添加到另一个产品阵列中,以便再次循环浏览它捕获Shopify收藏中的所有产品,shopify,liquid,Shopify,Liquid,当我在Shopify中循环浏览一个集合时,我想将该产品添加到另一个产品阵列中,以便再次循环浏览它 {% assign custom_products = '' %} {% for product in collections['all'].products %} {% assign custom_products = custom_products | append: product %} {% endfor %} 但当我再次遍历它时,我什么也得不到 {% for product in
{% assign custom_products = '' %}
{% for product in collections['all'].products %}
{% assign custom_products = custom_products | append: product %}
{% endfor %}
但当我再次遍历它时,我什么也得不到
{% for product in custom_products %}
{% endfor %}
当我转储
定制产品时
会得到productDropProductDropProductDrop…
等等。这是因为我正在构造一个字符串吗?我希望液体模板中的第二个for
循环在产品中移动,就像它是集合['all'].产品一样。有什么想法吗?你的例子不清楚。您正在遍历“所有产品”集合,试图复制它。复制收藏最好使用Shopify,而不是Liquid。@DavidLazar我正在有条件地将产品附加到自定义阵列中。我的问题是如何保持格式,以便我可以继续循环我的自定义数组。所有的产品限制为20。硬限制。目前为止你没注意到吗?@DavidLazar。。对我知道。但对于所讨论的查询,这是我认为可以实现的最接近的方法。
{% capture custom_products %}
{% for product in collections['all'].products %}
{{ custom_products }},{{ product.handle }}
{% endfor %}
{% endcapture %}
{% assign custom_products = custom_products | split: ',' %}
{% for product in custom_products %}
{{ all_products[product].title }}
{% endfor %}