In my table there are fields like o_old_price (old price) and o_price (new price).
Is there any how I can calculate the discount from these prices and sort using it.
I had modified the model.
[i]public discount;
public function getDiscount()
{
$discount = (($this->o_old_price - $this->o_price)/$this->o_old_price) * 100;
return (is_null($discount)?$discount:0);
}
[/i]
I added this criteria in controller. But I dont think it is the right way.
[i]$criteria->order = 't.discount desc';[/i]
I think Yii will have its own ways to handle such situations. Please help me to do these things.