it seems Shopify only allows for filtering by tags. If you want to filter by Vendor (which is a standard Shopify Field) you first need to create tags with the same name and manually use those tags in the filter sidebar.
Is this correct? Seems very unnecessary and more importantly makes dynamic updates difficult.
2
Answers
Shopify doesn’t allow for filtration by vendor at the moment (while keeping the collection relation to the vendor).
This was mentioned in a recent live Q&A with Shopify and it was confirmed that they are testing this. More info can be seen here: https://youtu.be/MDqDIIyxIcU?t=2078
You have to stick with the tags for now.
After almost 2 days of trial and error, plus lots of digging into forums and the documentation, I came up with this bit of code to create a working Vendor filter.
Please note the following:
Here are the important things worth mentioning:
onChange="window.location.href=this.value"
is a bit of JavaScript necessary to grab the value from the vendor dropdown and to update the web address (URL).for product_vendor in shop.vendors
is a bit of Liquid necessary to grab all vendors and provide them one at a time to the dropdown.if collection.current_vendor contains product_vendor
is also a bit of Liquid necessary when the vendor filter is in use. It checks for an active vendor filter and selects it in the dropdown after the page has reloaded.{{ product_vendor | url_for_vendor }}
provides the URL used by the JavaScript in #1 above.{{ product_vendor }}
provides the actual vendor name to the list.and collection.current_vendor == blank
tells the page to hide the Tag and Sort dropdowns if a vendor filter was selected.Here are the Shopify Docs which really helped me. This assumes you already understand the for loop and if statements which are a basic component of programming.