want to get the product sort collection product best-selling, price-descending and price_ascending

info_threeg
Shopify Partner
7 0 0

I  want to get the product sort collection product best-selling, price-descending and price_ascending usign custom code. 

{% assign productsnow = collection.products | sort: "best-selling" %}   
{% for product in productsnow limit: 4 %}         
{{product .title}}
{% endfor %}

{% assign expensiveproduct = collection.products | sort: 'price-descending' %}
{% for product in expensiveproduct limit: 4 %}         
{{product .title}}
{% endfor %}


{% assign productascending = collection.products | sort: "price-ascending" %}
{% for product in productascending limit: 4 %}
{{product .title}}
{% endfor %}

 Could you please let me know the issue how to fix this. 

 

Replies 2 (2)
Mike1974
Excursionist
22 0 2

Shopify already  has this based on their AI   

"Sort by best selling" 

info_threeg
Shopify Partner
7 0 0

Yes, I agree that shopify already  has this based on their AI   "Sort by best selling" . But we need to achive this using custom code. We need to built some custom feature.