【发布时间】:2019-03-11 15:08:09
【问题描述】:
我正在尝试按集合过滤我的相关产品。
每个产品都属于两个系列:一个用于材料,一个用于房间。
Material one 是一个自动收集带有特定标签的产品。
房间一是手动填充的。
当我进入产品页面时,我会像这样加载相关产品(相关产品必须与当前产品共享两个集合):
{% for related_product in collection.products %}
{% if product.collections[0].handle ==
related_product.collections[0].handle and product.collections[1].handle
== related_product.collections[1].handle and related_product.handle !=
product.handle %}
<div class="Carousel__Cell">
{% include 'product-item', product: related_product,
show_product_info:
section.settings.show_product_info, show_labels: true %}
</div>
{% endif %}
{% endfor %}
奇怪的是,这仅适用于某些产品。在其中一些产品中,product.collection 似乎为空,这没有任何意义!
所有产品都正确显示在正确的集合中。
问题发生在集合的上下文中(但我们需要让它在所有上下文中都有效)
【问题讨论】: