list vendors with counts, *without* creating a collection for each vendor

tony5280
Shopify Partner
61 6 18

Currently, I have something similar to this:

{% for vendor in shop.vendors %}
{% assign vendor_handle = vendor | handleize %}
{% assign vendor_product_count = collections[vendor_handle].products_count %}
{{ vendor }} ({{ vendor_product_count }}) first product:{{ collections[vendor_handle].products[0].handle }}
{% endfor %}

This example depends on the existence of a collection with the same name as the vendor.  I know that dynamic vendor collections exist, for example, /collections/vendors?q=vendor-that-doesn't-have-a-collection-defined

I would love to be able to address that dynamic collection, so that I can maintain a "by brand" nav without having to create a collection for each new vendor. 

Can anyone think of a way to do this?

0 Likes
tony5280
Shopify Partner
61 6 18

a shout into the void

0 Likes
gina-gregory
Shopify Expert
663 37 142

You could probably achieve that with javascript after the page loads by fetching each paginated page of the dynamic vendor collection and counting up the products.

0 Likes