Inheritance: extends yupe\models\YModel
Example #1
0
 public function actionDelete($id)
 {
     if (ImageGroup::model()->findByPk($id)->delete()) {
         Yii::app()->ajax->success(Yii::t('StoreModule.store', 'The group is successfully deleted'));
     }
     Yii::app()->ajax->error(Yii::t('StoreModule.store', 'Failed to delete group'));
 }
 /**
  * Редактирование товара.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if (Yii::app()->getRequest()->getIsPostRequest() && Yii::app()->getRequest()->getPost('Product')) {
         $attributes = Yii::app()->getRequest()->getPost('Product');
         $typeAttributes = Yii::app()->getRequest()->getPost('Attribute', []);
         $variants = Yii::app()->getRequest()->getPost('ProductVariant', []);
         $categories = Yii::app()->getRequest()->getPost('categories', []);
         if ($model->saveData($attributes, $typeAttributes, $variants, $categories)) {
             $this->updateProductImages($model);
             $this->uploadAttributesFiles($model);
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('StoreModule.store', 'Record was updated!'));
             if (!isset($_POST['submit-type'])) {
                 $this->redirect(['update', 'id' => $model->id]);
             } else {
                 $this->redirect([$_POST['submit-type']]);
             }
         } else {
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('StoreModule.store', 'Failed to save product!'));
         }
     }
     $searchModel = new ProductSearch('search');
     $searchModel->unsetAttributes();
     $searchModel->setAttributes(Yii::app()->getRequest()->getQuery('ProductSearch'));
     $this->render('update', ['model' => $model, 'searchModel' => $searchModel, 'imageGroup' => ImageGroup::model()]);
 }
Example #3
0
 public static function all()
 {
     return CHtml::listData(ImageGroup::model()->findAll(), 'id', 'name');
 }