コード例 #1
0
 /**
  * getDetail - Phương thức dùng để lấy dữ liệu
  */
 public function getDetail($product_id = null)
 {
     Yii::import('application.modules.products.models.ProductItem');
     $data = array();
     if ($product_id) {
         $data = ProductItem::model()->findByPk($product_id);
     }
     return $data;
 }
コード例 #2
0
 public function actionResetImage()
 {
     $uploadPath = YiiBase::getPathOfAlias('webroot') . '/files/products';
     @set_time_limit(0);
     $items = ProductItem::model()->findAll();
     foreach ($items as $item) {
         $thumbsPath = $uploadPath;
         $filename = $item->image;
         @unlink($thumbsPath . '/thumb_' . $filename);
         // thumbnails image
         Yii::import("ext.EPhpThumb.EPhpThumb");
         $thumb = new EPhpThumb();
         $thumb->init();
         //this is needed
         $thumb->create($uploadPath . '/' . $filename)->adaptiveResize(Yii::app()->getModule('products')->widthThumb, Yii::app()->getModule('products')->heightThumb)->save($thumbsPath . '/thumb_' . $filename);
     }
     echo 'Done!';
 }
コード例 #3
0
 /**
  * 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 = ProductItem::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }