Example #1
0
 public function showFav()
 {
     if (!empty($_SESSION['favorites'])) {
         $criteria_p = new CDbCriteria();
         $product_array_session = implode(',', array_unique($_SESSION['favorites']));
         $criteria_p->condition = '`t`.`id` IN (' . $product_array_session . ')';
         $criteria_p->with = array('catalog');
         $criteria_p->order = 'catid ASC';
         $criteria_p->limit = 3;
         $product = Production::model()->findAll($criteria_p);
         $product_count = Production::model()->findAll(array('condition' => '`t`.`id` IN (' . $product_array_session . ')'));
     } else {
         $product = array();
         $product_count = array();
     }
     $this->renderPartial('fav_box', array('favorites' => $product, 'counter' => $product_count));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Production::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }