Any way to sort alphabetically by vendor?

Highlighted
New Member
4 0 0

Hello. I am trying to get my store to sort alphabetically by vendor. It's an online record store and I would like it to sort by artist's last name, so Miles Davis sorts before Art Pepper (under D and P respectively instead of M and A). Since I can't do this by SKU, or by product title without using the names "Davis, Miles" and "Pepper, Art" (or even worse something like "Beatles, The") I was hoping I could enter the names in Vendor that way and sort them like that. I am using the Debut theme but am open to switching if there's a way to do this. Thanks!

0 Likes
Shopify Partner
134 4 14

Something like this should get a list of vendors by alphabet

 

{% assign chars = '' %}
{% for vendor in shop.vendors %}
    {% capture first_char %}{{ vendor | truncate: 1, ''  | upcase}}{% endcapture %}

    {% if forloop.first %}
        <div>
            <ul id="vendorlist">
    {% endif %}

    {% unless chars contains first_char %}
        {% unless forloop.first %}
              <div style="clear:both;"></div>
               </ul>
            </div>
        {% endunless %}

        <div>
            <h2>{{ first_char }}</h2>
               <ul>
        {% capture temp %}{{ chars }}{{ first_char }}{% endcapture %}
        {% assign chars = temp %}
    {% endunless %}

    <li><a href="/collections/vendors?q={{ vendor }}&sort_by=created-descending">{{vendor | capitalize}}</a></li>
{% endfor %}
0 Likes