当前位置: 首页>>代码示例>>PHP>>正文


PHP GroupReduction::deleteCategory方法代码示例

本文整理汇总了PHP中GroupReduction::deleteCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupReduction::deleteCategory方法的具体用法?PHP GroupReduction::deleteCategory怎么用?PHP GroupReduction::deleteCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GroupReduction的用法示例。


在下文中一共展示了GroupReduction::deleteCategory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

 public function delete()
 {
     if ((int) $this->id === 0 || (int) $this->id === (int) Configuration::get('PS_ROOT_CATEGORY')) {
         return false;
     }
     $this->clearCache();
     $deleted_children = $all_cat = $this->getAllChildren();
     $all_cat[] = $this;
     foreach ($all_cat as $cat) {
         /** @var Category $cat */
         $cat->deleteLite();
         if (!$this->hasMultishopEntries()) {
             $cat->deleteImage();
             $cat->cleanGroups();
             $cat->cleanAssoProducts();
             // Delete associated restrictions on cart rules
             CartRule::cleanProductRuleIntegrity('categories', array($cat->id));
             Category::cleanPositions($cat->id_parent);
             /* Delete Categories in GroupReduction */
             if (GroupReduction::getGroupsReductionByCategoryId((int) $cat->id)) {
                 GroupReduction::deleteCategory($cat->id);
             }
         }
     }
     /* Rebuild the nested tree */
     if (!$this->hasMultishopEntries() && (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree)) {
         Category::regenerateEntireNtree();
     }
     Hook::exec('actionCategoryDelete', array('category' => $this, 'deleted_children' => $deleted_children));
     return true;
 }
开发者ID:yewed,项目名称:share,代码行数:31,代码来源:Category.php

示例2: delete

    public function delete()
    {
        if ((int) $this->id === 0 or (int) $this->id === 1) {
            return false;
        }
        $this->clearCache();
        /* Get childs categories */
        $toDelete = array((int) $this->id);
        $this->recursiveDelete($toDelete, (int) $this->id);
        $toDelete = array_unique($toDelete);
        /* Delete category and its child from database */
        $list = sizeof($toDelete) > 1 ? implode(',', array_map('intval', $toDelete)) : (int) $this->id;
        Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'category` WHERE `id_category` IN (' . $list . ')');
        Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'category_lang` WHERE `id_category` IN (' . $list . ')');
        Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'category_product` WHERE `id_category` IN (' . $list . ')');
        Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'category_group` WHERE `id_category` IN (' . $list . ')');
        self::cleanPositions($this->id_parent);
        /* Delete category images and its children images */
        $tmpCategory = new Category();
        foreach ($toDelete as $id_category) {
            $tmpCategory->id = (int) $id_category;
            $tmpCategory->deleteImage();
        }
        /* Delete products which were not in others categories */
        $result = Db::getInstance()->ExecuteS('
		SELECT `id_product`
		FROM `' . _DB_PREFIX_ . 'product`
		WHERE `id_product` NOT IN (SELECT `id_product` FROM `' . _DB_PREFIX_ . 'category_product`)');
        foreach ($result as $p) {
            $product = new Product((int) $p['id_product']);
            if (Validate::isLoadedObject($product)) {
                $product->delete();
            }
        }
        /* Set category default to 1 where categorie no more exists */
        $result = Db::getInstance()->Execute('
		UPDATE `' . _DB_PREFIX_ . 'product`
		SET `id_category_default` = 1
		WHERE `id_category_default`
		NOT IN (SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category`)');
        /* Rebuild the nested tree */
        if (!isset($this->doNotRegenerateNTree) or !$this->doNotRegenerateNTree) {
            self::regenerateEntireNtree();
        }
        Module::hookExec('categoryDeletion', array('category' => $this));
        /* Delete Categories in GroupReduction */
        foreach ($toDelete as $category) {
            if (GroupReduction::getGroupReductionByCategoryId((int) $category)) {
                GroupReduction::deleteCategory($category);
            }
        }
        return true;
    }
开发者ID:greench,项目名称:prestashop,代码行数:53,代码来源:Category.php


注:本文中的GroupReduction::deleteCategory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。