Skip to content

Commit

Permalink
Merge pull request #1275 from shreesh-webkul/gli-2321-2
Browse files Browse the repository at this point in the history
Fixed: The parent category not set correctly while creating new category
  • Loading branch information
rohit053 authored Oct 4, 2024
2 parents 95bd4a6 + 7f034b2 commit a764304
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 1 addition & 3 deletions classes/helper/HelperTreeCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ private function fillTree(&$categories, $rootCategoryId)
$categoryId = (int)$category['id_category'];
$tree[$categoryId] = $category;
$tree[$categoryId]['value'] = $category['id_category'];
$tree[$categoryId]['input_name'] = 'categoryBox';

if (Category::hasChildren($categoryId, $this->getLang(), false, $this->getShop()->id)) {
$categoryChildren = Category::getChildren(
Expand Down Expand Up @@ -434,13 +433,13 @@ public function renderNodes($data = null, $root = false)

$html = '';
foreach ($data as $item) {
$item['input_name'] = $this->getInputName();
if (array_key_exists('children', $item)
&& !empty($item['children'])) {
$html .= $this->getContext()->smarty->createTemplate(
$this->getTemplateFile($this->getNodeFolderTemplate()),
$this->getContext()->smarty
)->assign(array(
'input_name' => $this->getInputName(),
'input_id' => $this->getInputId(),
'children' => $this->renderNodes($item['children']),
'node' => $item
Expand All @@ -450,7 +449,6 @@ public function renderNodes($data = null, $root = false)
$this->getTemplateFile($this->getNodeItemTemplate()),
$this->getContext()->smarty
)->assign(array(
'input_name' => $this->getInputName(),
'input_id' => $this->getInputId(),
'node' => $item
))->fetch();
Expand Down
3 changes: 2 additions & 1 deletion controllers/admin/AdminCategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,6 @@ public function processAdd()
{
$id_category = (int)Tools::getValue('id_category');
$id_parent = (int)Tools::getValue('id_parent');

// if true, we are in a root category creation
if (!$id_parent) {
$_POST['is_root_category'] = $_POST['level_depth'] = 1;
Expand Down Expand Up @@ -767,6 +766,8 @@ public function processUpdate()
$_POST['link_rewrite_'.$lang['id_lang']] = $this->object->link_rewrite[$lang['id_lang']];
}
}

return parent::processUpdate();
}

protected function setDeleteMode()
Expand Down

0 comments on commit a764304

Please sign in to comment.