{% paginate search.results by 24 %} {% for product in search.results %} {% comment %} Every product is in multiple auto collections that look like this: ["building consumables", "building consumables > solder & flux", "building consumables > solder & flux > rosin flux"] So we search for the _longest handle_ to find the leaf category of the product and link to that. {% endcomment %} {% assign collection_with_longest_handle = product.collections | sort: 'handle.size' | last %} {% assign modified_handle = collection_with_longest_handle.handle | remove_first: 'hardware-' %}
{{ product.title }} {{ product.title }}
{% endfor %} {% endpaginate %}