Commit b8f5bcc9a6bcab7ef3bf876d2b66a68ac1370281
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 | 215 | |
216 | 216 | public function beforeDelete() |
217 | 217 | { |
218 | - CategoryName::deleteAll(['category_id' => $this->category_id]); | |
218 | + | |
219 | 219 | if(!empty($this->products)){ |
220 | 220 | foreach($this->products as $product){ |
221 | 221 | $product->delete(); |
222 | 222 | } |
223 | 223 | } |
224 | 224 | $this->unlinkAll('product_category'); |
225 | + CategoryName::deleteAll(['category_id' => $this->category_id]); | |
225 | 226 | return true; |
226 | 227 | } |
227 | 228 | ... | ... |