Showing results for 
Search instead for 
Did you mean: 

Sort by % Off

Sort by % Off

Hi everyone !


I want to sort by % Off like below imageScreenshot from 2018-10-18 14-27-35.png




and here is my code 

->where('ROUND(((price_index.price - price_index.final_price)/price_index.price)*100,0)')
->order('ROUND(((price_index.price - price_index.final_price)/price_index.price)*100,0) DESC');
but my code not working Smiley Sad i'm new one working on magento 2. Can you help me to fix my code or guide me to shows right order ? Thanks

Re: Sort by % Off

I think Magento can only filter via attributes. Create an custom attribute called "discount" and activate the option sortable and calculate the % automatically if you save theproduct. 


After that you can sort in the frontend with the default magento engine.

If my answer is useful, please Accept as Solution & give Kudos

Re: Sort by % Off

Hello @BinhXuanNguyen


You need to rewrite magento files,
1. add your new options to default magento filter.
2. Add your logic to product collection file which create collection for page.

Was my answer helpful? You can accept it as a solution.
175+ Professional Extensions for M1 & M2
Need a developer?Just visit Contact Us Now