I want to make a top offers block where special offer products with the highest percentage discount are shown.
I have my special offer products showing and just wondering if something like below is possible to sort these by their discount percentage:
$_productCollection->addFinalPrice()
->addMinimalPrice()
->getSelect()
->where('price_index.final_price < price_index.price')
->limit(2);
->order('(price_index.price - price_index.final_price) / price_index.price' , 'DESC')
Failing that i would like latest offers (sorting by special from date descending) which i think should be like so:
$_productCollection->addFinalPrice()
->addMinimalPrice()
->getSelect()
->where('price_index.final_price < price_index.price')
->limit(2);
->order('special_from_date' , 'DESC')
However this is not working. Has anyone any suggestions for how to use sort properly within Magento 2?