Storefront Search: can I return the results by best-selling

I’ve learned how to return collection listings with “sort_by=best-selling”, but I want to be able to return my search results with the same sort order.

this request query has no effect on the sort order: “q=roses&sort_by=best-selling”.

Here’s a section of my search.liquid file that was edited by our developer in the past:

{% if item.object_type == 'product' %}
                
                  {% if item.compare_at_price > item.price %}
                    {% if item.price_varies %}
                      {% assign sale_price = item.price | money %}
                      {{ 'products.product.on_sale_from_html' | t: price: sale_price }}
                    {% else %}
                      {{ 'products.product.on_sale' | t }}
                      {{ item.price | money }}
                    {% endif %}
                    {{ 'products.product.regular_price' | t }}
                    ~~{{ item.compare_at_price | money }}~~
                  

                {% else %}
                  {% if item.price_varies %}
                    {% assign price = item.price | money %}
                    {{ 'products.product.from_lowest_price_html' | t: lowest_price: price }}
                  {% else %}
                    {{ item.price | money }}
                  {% endif %}
                {% endif %}
                {% unless item.available %}
                  {{ 'products.product.sold_out' | t }}
                {% endunless %}
              {% else %}
                

{{ item.content | strip_html | truncate: 120 }}

              {% endif %}

Can I edit this to return the results by best-seller?

Thanks - D

Hi @dstefani ,

Please refer: https://shopify.dev/api/liquid/objects/collection#collection-sort_options

Shopify does not support sort by best-seller. So you can just change according to the options above.

Hope it is clear to you.

If my answer can help you solve your issue, please mark it as a solution. Thank you and good luck.