The followings are the available columns in table 'product_special':
Inheritance: extends CActiveRecord
 public function actionUpdate()
 {
     $lid = Yii::app()->request->getParam('id');
     Until::isUpdateValid(array($lid), $this->companyId, $this);
     //0,表示企业任何时候都在云端更新。
     $model = ProductSpecial::model()->find('lid=:lid and dpid=:dpid', array(':lid' => $lid, ':dpid' => $this->companyId));
     $product = Product::model()->find('lid=:lid and dpid=:dpid and delete_flag=0', array(':lid' => $model->product_id, ':dpid' => $this->companyId));
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('ProductSpecial');
         $model->update_at = date('Y-m-d H:i:s', time());
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '修改成功'));
             $this->redirect(array('productSpecial/updatedetail', 'companyId' => $this->companyId, 'id' => $model->product_id));
         }
     }
     $this->render('update', array('model' => $model, 'product' => $product));
 }
Exemplo n.º 2
0
 public function afterDelete()
 {
     // delete dependencies
     ProductAttribute::model()->deleteAll("product_id={$this->cacheId}");
     ProductDescription::model()->deleteAll("product_id={$this->cacheId}");
     ProductDiscount::model()->deleteAll("product_id={$this->cacheId}");
     ProductFilter::model()->deleteAll("product_id={$this->cacheId}");
     ProductImage::model()->deleteAll("product_id={$this->cacheId}");
     ProductOption::model()->deleteAll("product_id={$this->cacheId}");
     ProductOptionValue::model()->deleteAll("product_id={$this->cacheId}");
     ProductRelated::model()->deleteAll("product_id={$this->cacheId}");
     ProductRelated::model()->deleteAll("related_id={$this->cacheId}");
     ProductReward::model()->deleteAll("product_id={$this->cacheId}");
     ProductSpecial::model()->deleteAll("product_id={$this->cacheId}");
     ProductToCategory::model()->deleteAll("product_id={$this->cacheId}");
     ProductToDownload::model()->deleteAll("product_id={$this->cacheId}");
     ProductToLayout::model()->deleteAll("product_id={$this->cacheId}");
     ProductToStore::model()->deleteAll("product_id={$this->cacheId}");
     Review::model()->deleteAll("product_id={$this->cacheId}");
     UrlAlias::model()->deleteAll("query='product_id={$this->cacheId}'");
     parent::afterDelete();
 }
Exemplo n.º 3
0
 public function validateProductSpecial()
 {
     if (isset($_POST['ProductSpecial'])) {
         $valid = true;
         $this->_productspecial = array();
         /*Yii::log( "ProductCreateAction: ".CVarDumper::dumpAsString( $_POST['ProductOption'] ),
         			CLogger::LEVEL_ERROR, "product.actions.create" 
         		);*/
         foreach ($_POST['ProductSpecial'] as $i => $special) {
             if (isset($_POST['ProductSpecial'][$i])) {
                 $special = new ProductSpecial();
                 $special->product_id = 0;
                 $special->attributes = $_POST['ProductSpecial'][$i];
                 $special->date_start = date('Y-m-d', strtotime($_POST['ProductSpecial'][$i]['date_start']));
                 $special->date_end = date('Y-m-d', strtotime($_POST['ProductSpecial'][$i]['date_end']));
                 $valid = $special->validate() && $valid;
                 $this->_productspecial[] = $special;
             }
         }
         if (!$valid) {
             return false;
         }
     }
     return true;
 }