Exemplo n.º 1
0
 /**
  * This is invoked after the record is deleted.
  */
 protected function afterDelete()
 {
     parent::afterDelete();
     $this->value->delete();
     Photo::deleteByProduct($this);
     ProductRelation::model()->deleteAll('pid=' . $this->id . ' OR pr_id=' . $this->id);
     CatalogRelation::model()->deleteAll('pr_id=' . $this->id);
 }
Exemplo n.º 2
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  */
 public function actionDelrel()
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $relation = ProductRelation::model()->findByAttributes(array('pid' => $_GET['pid'], 'pr_id' => $_GET['pr_id']));
         $relation->delete();
         #TODO: Delete photo and relation
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_POST['ajax'])) {
             $this->redirect(array('update', 'id' => $_GET['id']));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }