From cd28a48b2f048a0f30199d4fa53990716e847b27 Mon Sep 17 00:00:00 2001 From: vChabot Date: Tue, 28 Feb 2012 17:16:47 +0000 Subject: [PATCH] [-] BO : BugFix : #PSTEST-788 : Treeview is now handled with shop context in admin category controller --- classes/Category.php | 4 ++-- classes/helper/Helper.php | 8 +++++--- js/admin-categories-tree.js | 4 ++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/classes/Category.php b/classes/Category.php index ca5d6e614..090391439 100644 --- a/classes/Category.php +++ b/classes/Category.php @@ -781,7 +781,7 @@ class CategoryCore extends ObjectModel if (!$shop) $shop = Context::getContext()->shop; - $id_shop = Configuration::get('PS_SHOP_DEFAULT'); + $id_shop = $shop->id ? $shop->id : Configuration::get('PS_SHOP_DEFAULT'); $selected_cat = explode(',', str_replace(' ', '', $selected_cat)); $sql = 'SELECT c.`id_category`, c.`level_depth`, cl.`name`, IF(( SELECT COUNT(*) @@ -806,7 +806,7 @@ class CategoryCore extends ObjectModel AND cs.`id_shop` = '.(int)$shop->id; $sql .= ' AND c.`id_parent` = '.(int)$id_parent.' - ORDER BY `position` ASC'; + ORDER BY cs.`position` ASC'; return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } diff --git a/classes/helper/Helper.php b/classes/helper/Helper.php index babf83d7a..6199161cc 100755 --- a/classes/helper/Helper.php +++ b/classes/helper/Helper.php @@ -161,6 +161,7 @@ class HelperCore * @param bool $use_search display a find category search box * @param array $disabled_categories * @param bool $use_in_popup + * @param bool $use_shop_context * @return string */ public function renderCategoryTree($root = null, @@ -169,7 +170,8 @@ class HelperCore $use_radio = false, $use_search = false, $disabled_categories = array(), - $use_in_popup = false) + $use_in_popup = false, + $use_shop_context = false) { $translations = array( 'selected' => $this->l('selected'), @@ -229,10 +231,10 @@ class HelperCore if (!$use_in_popup) $html .= ' $(document).ready(function(){ - buildTreeView(); + buildTreeView('.$use_shop_context.'); });'; else - $html .= 'buildTreeView();'; + $html .= 'buildTreeView('.$use_shop_context.');'; $html .= ''; $html .= ' diff --git a/js/admin-categories-tree.js b/js/admin-categories-tree.js index f8b562c99..0442d83bf 100755 --- a/js/admin-categories-tree.js +++ b/js/admin-categories-tree.js @@ -35,6 +35,9 @@ var id_category_root = 0; function buildTreeView() { + use_shop_context = false; + if (buildTreeView.arguments[0]) + use_shop_context = true; $("#categories-treeview").treeview({ url : 'ajax.php', toggle: function () { callbackToggle($(this)); }, @@ -43,6 +46,7 @@ function buildTreeView() async: true, data: { getChildrenCategories : true, + use_shop_context : use_shop_context, selectedCat: selectedCat } }