public function afterDelete() { // delete children $children = Category::model()->findAll("parent_id={$this->cacheId}"); foreach ($children as $child) { $child->delete(); } // delete dependencies CategoryPath::model()->deleteAll("category_id={$this->cacheId}"); CategoryDescription::model()->deleteAll("category_id={$this->cacheId}"); CategoryFilter::model()->deleteAll("category_id={$this->cacheId}"); CategoryToStore::model()->deleteAll("category_id={$this->cacheId}"); CategoryToLayout::model()->deleteAll("category_id={$this->cacheId}"); ProductToCategory::model()->deleteAll("category_id={$this->cacheId}"); UrlAlias::model()->deleteAll("query='category_id={$this->cacheId}'"); parent::afterDelete(); }
public function clearAllCategoriesRelations() { ProductToCategory::model()->deleteAllByAttributes(array('product_id' => $this->product_id)); }