I’ve a large find method with a lot of CDbCriteria conditions, that’s currently located in my ProductController file. Is it better to do this as a method/function in the model itself like the search method.
$criteria = new CDbCriteria;
$criteria->alias = "p";
$criteria->select = "p.id, p.lastModified, ProductLangs.title as title, ProductLangs.description as description, ProductLangs.keywords as keywords, ProductLangs.text as text, ProductLangs.visible as visible";
$criteria->with = array(
'ProductLangs' => array('alias' => 'ProductLangs'),
'ProductProductgroups' => array('alias' => 'ProductProductgroups'),
);
$criteria->condition = "lang_id = :langid";
$criteria->addCondition("ProductProductgroups.product_id = p.id");
$criteria->addCondition("ProductLangs.id = :plid");
$criteria->params = array(':langid' => $currentLang, ':plid' => $id);
$criteria->together = true;
$model = Product::model()->find($criteria);