【发布时间】:2021-01-26 15:57:50
【问题描述】:
对于客户,我正在构建一种方法来选择产品页面的推荐产品部分中显示的产品。为了实现这一点,我考虑将我想展示的产品的把手插入产品的标签部分。
所以我可以遍历产品中的所有标签,然后为每个标签获取产品对象并显示它。问题是这段代码似乎不起作用:
{% for tag in tags %}
{% for single_product in all_products[tag] %}
{{ single_product }}
{% endfor %}
{% endfor %}
此代码确实有效:
{% for tag in tags %}
{% for single_product in all_products[tag].title %} <---- Added .title
{{ single_product }}
{% endfor %}
{% endfor %}
遗憾的是,我需要整个产品对象来显示它,而不仅仅是产品标题。如何在 shopify 中实现这一点?
附加信息:此代码位于framework--product-recommendations.liquid 文件中
【问题讨论】:
-
我认为您需要查看
collection.products,read more -
@Onkar 谢谢!这非常有效!
-
很高兴知道它对您有帮助。