Display all vendors in a given collection

Highlighted
Tourist
23 0 1

Hello everyone,
I want to put a list of my most popular vendors on my 404 page. I've created a collection with 10 vendors and added the following code to my 404.

{% for product_vendor in collections.popular-brands.product_vendor %}
<ul>
<li>{{ product_vendor }}</li>
</ul>
{% endfor %}

I've tried all kinds of tweaks, but I can't seem to get it to work - any suggestions would be much appreciated! 
Thanks,

P.J. 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
5704 1 326

Hello P.J. :)

Try this:

<ul>
{% for product in collections.popular-brands.products %}
  <li>{{ product.vendor }}</li>
{% endfor %}
</ul>

Let me know how that goes!

0 Likes
Highlighted
Tourist
23 0 1

Hi Caroline,
Thanks for getting back to me, when I try that I get a long list of just the first brand in my 'popular brands' collection. It seems the system is listing the brand associated with each product in my collection, so if I have multiple products from the same brand, it duplicates the brand in the list. Is there a way that I can get it to only display each brand once?

P.J.

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
5704 1 326

Ah okay, I thought you had only one product per brand in your collection.

How about:

<ul>
{% for vendor in collections.popular-brands.all_vendors %}
  <li>{{ vendor }}</li>
{% endfor %}
</ul>

Or, even:

<ul>
{% for vendor in shop.vendors %}
  <li>{{ vendor }}</li>
{% endfor %}
</ul>

 

0 Likes
Highlighted
Tourist
23 0 1

Perfect! Thank you Caroline...

P.J.

0 Likes
Highlighted
New Member
1 0 0

@Caroline_Schnap How can we display all vendors from collection in same sorting order with the way it is setup in the condition of collection?

Is it even possible?

0 Likes