本文整理汇总了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;
}
示例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;
}