From eaeeac8dddcc02e0f38bbf1d0c98753b0c92e131 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 24 Sep 2024 16:14:01 +0530 Subject: [PATCH 1/3] Fixed: The parent category not set correctly while creating new category --- controllers/admin/AdminCategoriesController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminCategoriesController.php b/controllers/admin/AdminCategoriesController.php index 5576d3de60..f1512047fa 100644 --- a/controllers/admin/AdminCategoriesController.php +++ b/controllers/admin/AdminCategoriesController.php @@ -720,12 +720,13 @@ public function processForceDeleteImage() public function processAdd() { $id_category = (int)Tools::getValue('id_category'); - $id_parent = (int)Tools::getValue('id_parent'); - + $id_parent = (int)Tools::getValue('categoryBox'); // if true, we are in a root category creation if (!$id_parent) { $_POST['is_root_category'] = $_POST['level_depth'] = 1; $_POST['id_parent'] = $id_parent = (int)Configuration::get('PS_ROOT_CATEGORY'); + } else { + $_POST['id_parent'] = $id_parent; } if ($id_category) { From 72e4a2de549b19417329eeb106c8841c37f883e1 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 27 Sep 2024 11:02:25 +0530 Subject: [PATCH 2/3] Fixed: Admin is unable to update the categories --- controllers/admin/AdminCategoriesController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controllers/admin/AdminCategoriesController.php b/controllers/admin/AdminCategoriesController.php index f1512047fa..1048ae3aac 100644 --- a/controllers/admin/AdminCategoriesController.php +++ b/controllers/admin/AdminCategoriesController.php @@ -759,6 +759,7 @@ public function processUpdate() // @todo remove this after adding link_rewrite form option // currently have removed link_rewrite as it is currently not required // so adding link_rewrite in $_POST + $_POST['id_parent'] = $id_parent = (int)Tools::getValue('categoryBox'); if (!Validate::isLoadedObject($this->object)) { foreach (Language::getLanguages(true) as $lang) { $_POST['link_rewrite_'.$lang['id_lang']] = Tools::link_rewrite(Tools::getValue('name_'.$lang['id_lang'])); @@ -768,6 +769,8 @@ public function processUpdate() $_POST['link_rewrite_'.$lang['id_lang']] = $this->object->link_rewrite[$lang['id_lang']]; } } + + return parent::processUpdate(); } protected function setDeleteMode() From 7f034b259d909815442c6bf6936d0835392e3333 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 1 Oct 2024 12:40:39 +0530 Subject: [PATCH 3/3] updated category tree input field name --- classes/helper/HelperTreeCategories.php | 4 +--- controllers/admin/AdminCategoriesController.php | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/classes/helper/HelperTreeCategories.php b/classes/helper/HelperTreeCategories.php index e18583273a..d751307361 100644 --- a/classes/helper/HelperTreeCategories.php +++ b/classes/helper/HelperTreeCategories.php @@ -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( @@ -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 @@ -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(); diff --git a/controllers/admin/AdminCategoriesController.php b/controllers/admin/AdminCategoriesController.php index 1048ae3aac..8a979155db 100644 --- a/controllers/admin/AdminCategoriesController.php +++ b/controllers/admin/AdminCategoriesController.php @@ -720,13 +720,11 @@ public function processForceDeleteImage() public function processAdd() { $id_category = (int)Tools::getValue('id_category'); - $id_parent = (int)Tools::getValue('categoryBox'); + $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; $_POST['id_parent'] = $id_parent = (int)Configuration::get('PS_ROOT_CATEGORY'); - } else { - $_POST['id_parent'] = $id_parent; } if ($id_category) { @@ -759,7 +757,6 @@ public function processUpdate() // @todo remove this after adding link_rewrite form option // currently have removed link_rewrite as it is currently not required // so adding link_rewrite in $_POST - $_POST['id_parent'] = $id_parent = (int)Tools::getValue('categoryBox'); if (!Validate::isLoadedObject($this->object)) { foreach (Language::getLanguages(true) as $lang) { $_POST['link_rewrite_'.$lang['id_lang']] = Tools::link_rewrite(Tools::getValue('name_'.$lang['id_lang']));