Shopify每个标签的计数

Shopify每个标签的计数,shopify,Shopify,我是shopfiy的新手。我添加了黑色、蓝色、绿色等标签。 现在我想让伯爵看看 黑色(12) 蓝色(1) 绿色(4) 有人帮我吗 谢谢我对类似问题的回答可能会对您有所帮助: 要获得具有给定标签的所有产品的计数,您需要在产品上循环并手动计数 例如: {% assign collection = collections.all %} {% for tag in collection.all_tags %} {% assign products_count = 0 %} {% for

我是shopfiy的新手。我添加了黑色、蓝色、绿色等标签。 现在我想让伯爵看看

黑色(12)

蓝色(1)

绿色(4)

有人帮我吗


谢谢

我对类似问题的回答可能会对您有所帮助:

要获得具有给定标签的所有产品的计数,您需要在产品上循环并手动计数

例如:

{% assign collection = collections.all %}

{% for tag in collection.all_tags %}
    {% assign products_count = 0 %}
    {% for product in collection.products %}
        {% if product.tags contains tag %}
            {% assign products_count = products_count | plus: 1 %}
        {% endif %}
    {% endfor %}

    <p>{{ tag }} ({{ products_count }})</p>
{% endfor %}
{%assign collection=collections.all%}
{%用于集合中的标记。所有_标记%}
{%assign products\u count=0%}
{%用于集合中的产品。产品%}
{%如果product.tags包含标记%}
{%assign products_count=products_count |加:1%}
{%endif%}
{%endfor%}
{{tag}}({{products\u count}})

{%endfor%}
Steph有上述解决方法。然而,这项功能刚刚在shopify/liquid项目中被请求,希望它能被接受:@Steph Sharp,你能在这个链接中帮助我吗