Easy Access to Vendors and Product Types in Liquid

Jonathan Rudenberg

If you've ever wanted to allow customers to browse by product vendor or type, we just added a feature that allows you to do this easily. Shopify uses Liquid for shop templates, and you can now get lists of product vendors and types in Liquid.

For example, to make a list of links to each vendor in a shop, you can use this code:

{% for product_vendor in shop.vendors %}
  <li>{{ product_vendor | link_to_vendor  }}</li>
{% endfor %}

Or, to make a list of links to each product type in a collection, you can now do this:

{% for product_type in collection.all_types %}
  <li>{{ product_type | link_to_type  }}</li>
{% endfor %}

Previously to get the same information, you had to use an ugly workaround like this:

{% assign vendor_list = '' %}
{% for product in collections.all.all_products %}
    {% if vendor_list contains product.vendor %}
    {% else %}
        <li>{{ product.vendor }}</li>
        {% capture temp %}{{ vendor_list }}{{ product.vendor }}{% endcapture %}
        {% assign vendor_list = temp %}
    {% endif %}
{% endfor %}

The four variables that were added are


Take a look at the Shop and Collection Liquid documentation in the wiki for more details.