Пример #1
0
 public function delete()
 {
     if ((int) $this->category_id === 0 || (int) $this->category_id === 1) {
         return false;
     }
     $this->clearCache();
     $allCategories = $this->getAllChildren();
     $allCategories[] = $this;
     foreach ($allCategories as $category) {
         $category->deleteLite();
         if (!$this->hasMultishopEntries()) {
             $category->deleteImage();
             $category->cleanGroups();
             $category->cleanAssoProducts();
             // Delete associated restrictions on cart rules
             JeproshopCartRuleModelCartRule::cleanProductRuleIntegrity('categories', array($category->category_id));
             JeproshopCategoryModelCategory::cleanPositions($category->parent_id);
             /* Delete Categories in GroupReduction */
             if (JeproshopGroupReductionModelGroupReduction::getGroupsReductionByCategoryId((int) $category->category_id)) {
                 JeproshopGroupReductionModelGroupReduction::deleteCategory($category->category_id);
             }
         }
     }
     /* Rebuild the nested tree */
     if (!$this->hasMultishopEntries() && (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree)) {
         JeproshopCategoryModelCategory::regenerateEntireNtree();
     }
     Hook::exec('actionCategoryDelete', array('category' => $this));
     return true;
 }