Commit b8f5bcc9a6bcab7ef3bf876d2b66a68ac1370281

Authored by Administrator
1 parent 7369821d

20.07.16

Showing 1 changed file with 2 additions and 1 deletions   Show diff stats
common/modules/product/models/Category.php
@@ -215,13 +215,14 @@ class Category extends \yii\db\ActiveRecord @@ -215,13 +215,14 @@ class Category extends \yii\db\ActiveRecord
215 215
216 public function beforeDelete() 216 public function beforeDelete()
217 { 217 {
218 - CategoryName::deleteAll(['category_id' => $this->category_id]); 218 +
219 if(!empty($this->products)){ 219 if(!empty($this->products)){
220 foreach($this->products as $product){ 220 foreach($this->products as $product){
221 $product->delete(); 221 $product->delete();
222 } 222 }
223 } 223 }
224 $this->unlinkAll('product_category'); 224 $this->unlinkAll('product_category');
  225 + CategoryName::deleteAll(['category_id' => $this->category_id]);
225 return true; 226 return true;
226 } 227 }
227 228