show product vendor on collection page

I am working with a shopify theme and trying to output the product vendor information on the main collection page. I have tried placing <p>{{ product.vendor | link_to_vendor }}</p> in multiple places which worked in another area of my theme but I am not having any luck -- can someone please help to explain how I can accomplish this? The code below is for my collection.liquid file

 {% capture collectionDescription %} {% if collection.description != blank and settings.collection-show-description %} <div> {{ collection.description }} </div> {% endif %} {% endcapture %} {% if collection.image and settings.collection-show-featured-image %} <div> <div> <h1>{{ collection.title }}</h1> {{ collectionDescription }} </div> </div> {% elsif collection.handle == 'all' %} <h1>{{ 'collections.collection.all_products' | t }}</h1> {{ collectionDescription }} {% else %} <h1>{{ 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> {% 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> <div> {% if current_tags %} {{ current_tags.first }} {% else %} {{ 'collections.collection.browse' | t }} {% endif %} </div> <select> {% 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> {% for product in collection.products %} {% include 'product-list-item' %} {% else %} <p>{{ 'collections.collection.no_products' | t }}</p> {% endfor %} </div> {% if paginate.previous or paginate.next %} {% include 'pagination' %} {% endif %} {% endpaginate %} 

enter image description here

2 Answers

A product has a vendor. As you point out, the simple Liquid construct is product.vendor. So when you are looping through all the products in a collection, you certainly do have access to them. So what is your actual problem? If you wanted to display the vendor, best place seems to be in your include file 'product-list-item' since that is where your product will be instantiated.

2

I had to do this in a collection template where {{ product.vendor }} doesn't work because the product object isn't readily available. Here's how that looked:

{% for product_vendor in collection.all_vendors %} {{ product_vendor | link_to_vendor }} {% endfor %} 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like