You can put on $model->search() method this:
$criteria=new CDbCriteria;
$criteria->select = "t.*, t.price - (t.price * t.discount/100) as total_price";
// EDITED: Added for Sort:
$sort = new CSort();
$sort->attributes = array(
'defaultOrder'=>'name ASC',
'total_price'=>array(
'asc'=>'total_price ASC',
'desc'=>'total_price DESC',
),
'*', // Add order in the other fields.
);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'sort'=>$sort, // Added to sort.
);
And create a not persistence attribute on "Product" model Class:
public $total_price;
Finally put 'total_price' on rules() in array with ('safe', 'on'=>'search'), something like this:
array('id, name, price, discount, total_price', 'safe', 'on'=>'search'),