0
if($currentOrder == "discount"){
     $subject->getCollection()->order('((price_index.price - price_index.final_price) / price_index.price)', 'DESC');
}

how i get the discounted products at sort by option.

1

You can choose to create a custom module to help you with custom sorting.

https://github.com/bogdanpisica/Magento2-ProductSort

Here is an example of the custom sorting mode, you can use it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.