相关产品没有出现在shopify上

时间:2014-04-16 09:03:54

标签: php shopify liquid

我在相关产品上有这个代码:

<h3>HAVE YOU TRIED...</h3>  
{% assign max = 10 %}
{% assign count = '' %}
{% assign list = '' %}
{% capture list %},{{ product.id }}{% endcapture %}

{% for collection in product.collections %}
    {% if collection.handle contains 'related' %}
        {% for product_related in collection.products %}
            {% capture id %},{{ product_related.id }}{% endcapture %}
            {% unless list contains id %}
                {% if count.size < max and product_related.images.size > 0 %} 
                    <div class="rel-product">
                        <div class="rel-img">
                          {% for image in product_related.images offset:1 limit:1 %}
                                <a href="{{ product_related.url | escape }}"><img src="{{ image.src | product_img_url: 'compact' }}}" alt="" /></a>
                            {% endfor %}
                        </div>

                        <div class="rel-cnt">
                            <h6><a href="{{ product_related.url | escape }}">{{ product_related.title }}</a></h6>
                            <p>{{ variant.option1 }}</p>
                            <span class="price">{{ product_related.price | money }}</span>
                        </div>
                    </div>
                    {% capture count %}{{ count }}.{% endcapture %}
                    {% capture list %}{{ list }}{{ id }}{% endcapture %}
                {% endif %}
            {% endunless %}
        {% endfor %}
    {% endif %}
{% endfor %}

它似乎适用于一个集合中的产品,但对于另一个集合中的产品完全没有,“你试过”的盒子是空的。任何人都可以告诉我这个代码在shopify中选择相关产品的行为以及为什么它可能没有显示该集合中的项目的任何相关产品。

1 个答案:

答案 0 :(得分:-1)

首先打印您的'产品'数组,并检查它会在检查其他数据时返回给您。

相关问题