Ad

Show Product Vendor On Collection Page

- 1 answer

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 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 %}

enter image description here

Ad

Answer

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.

Ad
source: stackoverflow.com
Ad