Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
捕获Shopify收藏中的所有产品_Shopify_Liquid - Fatal编程技术网

捕获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

当我在Shopify中循环浏览一个集合时,我想将该产品添加到另一个产品阵列中,以便再次循环浏览它

{% 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 %}