在产品系列页面上显示产品供应商
show product vendor on collection page
我正在使用 shopify 主题并尝试在主产品系列页面上输出产品供应商信息。我曾尝试将 <p>{{ product.vendor | link_to_vendor }}</p>
放置在多个位置,这些位置在我的主题的另一个区域起作用,但我没有任何运气 - 有人可以帮助解释我如何才能做到这一点吗?下面的代码适用于我的 collection.liquid 文件
{% capture collectionDescription %}
{% if collection.description != blank and settings.collection-show-description %}
<div class="collection-description rte">
{{ collection.description }}
</div>
{% endif %}
{% endcapture %}
{% if collection.image and settings.collection-show-featured-image %}
<div class="page-title collection-header-wrapper" style="background-image: url({{ collection.image.src | collection_img_url: '1024x1024' }});">
<div class="collection-header">
<h1>{{ collection.title }}</h1>
{{ collectionDescription }}
</div>
</div>
{% elsif collection.handle == 'all' %}
<h1 class="page-title">{{ 'collections.collection.all_products' | t }}</h1>
{{ collectionDescription }}
{% else %}
<h1 class="page-title">{{ collection.title }}</h1>
{{ collectionDescription }}
{% endif %}
{% assign productsPerPage = settings.collection-products-per-row | times: settings.collection-number-of-rows %}
{% paginate collection.products by productsPerPage %}
{% if collection.all_tags.size > 0 and settings.collection-enable-tag-filtering %}
<div class="collection-tag-selector">
{% assign fallback = '' %}
{% if collection.handle %}
{% capture link %}/collections/{{ collection.handle }}{% endcapture %}
{% assign fallback = link %}
{% elsif collection.products.first.type == collection.title %}
{% capture link %}{{ collection.title | url_for_type }}{% endcapture %}
{% assign fallback = link %}
{% elsif collection.products.first.vendor == collection.title %}
{% capture link %}{{ collection.title | url_for_vendor }}{% endcapture %}
{% assign fallback = link %}
{% endif %}
<div class="select-wrapper">
<div class="selected-text">
{% if current_tags %}
{{ current_tags.first }}
{% else %}
{{ 'collections.collection.browse' | t }}
{% endif %}
</div>
<select data-fallback-url="{{ fallback }}">
{% if current_tags %}
<option name="reset">-- {{ 'collections.collection.clear' | t }} --</option>
{% else %}
<option name="browse" selected disabled>{{ 'collections.collection.browse' | t }}</option>
{% endif %}
{% for tag in collection.all_tags %}
{% if current_tags contains tag %}
<option name="{{ tag | handle }}" selected>{{ tag }}</option>
{% else %}
<option name="{{ tag | handle }}">{{ tag }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
{% endif %}
<div class="collection-products products-per-row-{{settings.collection-products-per-row}}">
{% for product in collection.products %}
{% include 'product-list-item' %}
{% else %}
<p class="empty">{{ 'collections.collection.no_products' | t }}</p>
{% endfor %}
</div>
{% if paginate.previous or paginate.next %}
{% include 'pagination' %}
{% endif %}
{% endpaginate %}
一个产品有一个供应商。正如您所指出的,简单的 Liquid 结构是 product.vendor。因此,当您遍历集合中的所有产品时,您当然可以访问它们。那么你的实际问题是什么?如果您想显示供应商,最好的地方似乎是在您的包含文件“product-list-item”中,因为那是您的产品将被实例化的地方。
我不得不在 {{ product.vendor }}
不起作用的集合模板中执行此操作,因为产品对象不容易获得。这是它的样子:
{% for product_vendor in collection.all_vendors %}
{{ product_vendor | link_to_vendor }}
{% endfor %}
我正在使用 shopify 主题并尝试在主产品系列页面上输出产品供应商信息。我曾尝试将 <p>{{ product.vendor | link_to_vendor }}</p>
放置在多个位置,这些位置在我的主题的另一个区域起作用,但我没有任何运气 - 有人可以帮助解释我如何才能做到这一点吗?下面的代码适用于我的 collection.liquid 文件
{% capture collectionDescription %}
{% if collection.description != blank and settings.collection-show-description %}
<div class="collection-description rte">
{{ collection.description }}
</div>
{% endif %}
{% endcapture %}
{% if collection.image and settings.collection-show-featured-image %}
<div class="page-title collection-header-wrapper" style="background-image: url({{ collection.image.src | collection_img_url: '1024x1024' }});">
<div class="collection-header">
<h1>{{ collection.title }}</h1>
{{ collectionDescription }}
</div>
</div>
{% elsif collection.handle == 'all' %}
<h1 class="page-title">{{ 'collections.collection.all_products' | t }}</h1>
{{ collectionDescription }}
{% else %}
<h1 class="page-title">{{ collection.title }}</h1>
{{ collectionDescription }}
{% endif %}
{% assign productsPerPage = settings.collection-products-per-row | times: settings.collection-number-of-rows %}
{% paginate collection.products by productsPerPage %}
{% if collection.all_tags.size > 0 and settings.collection-enable-tag-filtering %}
<div class="collection-tag-selector">
{% assign fallback = '' %}
{% if collection.handle %}
{% capture link %}/collections/{{ collection.handle }}{% endcapture %}
{% assign fallback = link %}
{% elsif collection.products.first.type == collection.title %}
{% capture link %}{{ collection.title | url_for_type }}{% endcapture %}
{% assign fallback = link %}
{% elsif collection.products.first.vendor == collection.title %}
{% capture link %}{{ collection.title | url_for_vendor }}{% endcapture %}
{% assign fallback = link %}
{% endif %}
<div class="select-wrapper">
<div class="selected-text">
{% if current_tags %}
{{ current_tags.first }}
{% else %}
{{ 'collections.collection.browse' | t }}
{% endif %}
</div>
<select data-fallback-url="{{ fallback }}">
{% if current_tags %}
<option name="reset">-- {{ 'collections.collection.clear' | t }} --</option>
{% else %}
<option name="browse" selected disabled>{{ 'collections.collection.browse' | t }}</option>
{% endif %}
{% for tag in collection.all_tags %}
{% if current_tags contains tag %}
<option name="{{ tag | handle }}" selected>{{ tag }}</option>
{% else %}
<option name="{{ tag | handle }}">{{ tag }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
{% endif %}
<div class="collection-products products-per-row-{{settings.collection-products-per-row}}">
{% for product in collection.products %}
{% include 'product-list-item' %}
{% else %}
<p class="empty">{{ 'collections.collection.no_products' | t }}</p>
{% endfor %}
</div>
{% if paginate.previous or paginate.next %}
{% include 'pagination' %}
{% endif %}
{% endpaginate %}
一个产品有一个供应商。正如您所指出的,简单的 Liquid 结构是 product.vendor。因此,当您遍历集合中的所有产品时,您当然可以访问它们。那么你的实际问题是什么?如果您想显示供应商,最好的地方似乎是在您的包含文件“product-list-item”中,因为那是您的产品将被实例化的地方。
我不得不在 {{ product.vendor }}
不起作用的集合模板中执行此操作,因为产品对象不容易获得。这是它的样子:
{% for product_vendor in collection.all_vendors %}
{{ product_vendor | link_to_vendor }}
{% endfor %}