Merge branch 'ticket-11201-SlowCategoryCreation' into develop
This commit is contained in:
commit
79a1d1ec71
@ -380,6 +380,12 @@ class AdminCategories extends AdminTab
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
echo '<a href="'.__PS_BASE_URI__.substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)).'?tab=AdminCatalog&add'.$this->table.'&id_parent='.Tools::getValue('id_category', 1).'&token='.($token!=NULL ? $token : $this->token).'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add a new subcategory').'</a>';
|
||||
echo '<div style="margin:10px;">';
|
||||
|
||||
/**
|
||||
* @Override regenerateEntireNTree
|
||||
*/
|
||||
echo '<br/><a onclick="return confirm(\''.$this->l('Regenerate entire categories tree ?').'\');" class="button btn" href="'.__PS_BASE_URI__.substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)).'?tab=AdminCatalog®enerateTree&token='.($token!=NULL ? $token : $this->token).'"">' . $this->l('Regenerate NTree') . '</a><br/>';
|
||||
|
||||
$this->displayList($token);
|
||||
echo '</div>';
|
||||
}
|
||||
@ -390,6 +396,13 @@ class AdminCategories extends AdminTab
|
||||
|
||||
$this->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
|
||||
|
||||
/**
|
||||
* @Override regenerate Ntree
|
||||
*/
|
||||
if (Tools::isSubmit('regenerateTree')){
|
||||
Category::regenerateEntireNtree();
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitAdd'.$this->table))
|
||||
{
|
||||
if ($id_category = (int)(Tools::getValue('id_category')))
|
||||
|
@ -1,5 +1,38 @@
|
||||
<?php
|
||||
class Category extends CategoryCore {
|
||||
class Category extends CategoryCore {
|
||||
|
||||
public function add($autodate = true, $nullValues = false) {
|
||||
if(!$this->id_parent) {
|
||||
$this->id_parent = 1;
|
||||
}
|
||||
$this->doNotRegenerateNTree = true;
|
||||
return parent::add($autodate, $nullValues);
|
||||
}
|
||||
|
||||
public function update($nullValues = false){
|
||||
|
||||
$this->doNotRegenerateNTree = true;
|
||||
$current = Db::getInstance()->getRow('SELECT `position`, `id_parent` FROM `' . _DB_PREFIX_ . 'category` WHERE `id_category` = ' . (int) $this->id);
|
||||
if (!$current)
|
||||
return parent::update($nullValues);
|
||||
if ((int) $current['position'] != (int) $this->position || (int) $current['id_parent'] != (int) $this->id_parent)
|
||||
return parent::update($nullValues);
|
||||
|
||||
// Do not clean positions
|
||||
$this->updateGroup($this->groupBox);
|
||||
$this->level_depth = $this->calcLevelDepth();
|
||||
|
||||
$ObjectModelReflectionUpdate = new ReflectionMethod(get_parent_class(get_parent_class($this)), 'update');
|
||||
$ret = $ObjectModelReflectionUpdate->invoke($this, $nullValues);
|
||||
if (!isset($this->doNotRegenerateNTree) OR !$this->doNotRegenerateNTree)
|
||||
{
|
||||
Category::regenerateEntireNtree();
|
||||
$this->recalculateLevelDepth($this->id_category);
|
||||
}
|
||||
Module::hookExec('categoryUpdate', array('category' => $this));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getProducts($id_lang, $p, $n, $orderBy = NULL, $orderWay = NULL, $getTotal = false, $active = true, $random = false, $randomNumberProducts = 1, $checkAccess = true)
|
||||
{
|
||||
global $cookie;
|
||||
|
Loading…
Reference in New Issue
Block a user