[-] BO : BugFix : #PSTEST-788 : Treeview is now handled with shop context in admin category controller

This commit is contained in:
vChabot
2012-02-28 17:16:47 +00:00
parent 04d7e869d9
commit cd28a48b2f
3 changed files with 11 additions and 5 deletions
+2 -2
View File
@@ -781,7 +781,7 @@ class CategoryCore extends ObjectModel
if (!$shop) if (!$shop)
$shop = Context::getContext()->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)); $selected_cat = explode(',', str_replace(' ', '', $selected_cat));
$sql = 'SELECT c.`id_category`, c.`level_depth`, cl.`name`, IF(( $sql = 'SELECT c.`id_category`, c.`level_depth`, cl.`name`, IF((
SELECT COUNT(*) SELECT COUNT(*)
@@ -806,7 +806,7 @@ class CategoryCore extends ObjectModel
AND cs.`id_shop` = '.(int)$shop->id; AND cs.`id_shop` = '.(int)$shop->id;
$sql .= ' $sql .= '
AND c.`id_parent` = '.(int)$id_parent.' 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); return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
} }
+5 -3
View File
@@ -161,6 +161,7 @@ class HelperCore
* @param bool $use_search display a find category search box * @param bool $use_search display a find category search box
* @param array $disabled_categories * @param array $disabled_categories
* @param bool $use_in_popup * @param bool $use_in_popup
* @param bool $use_shop_context
* @return string * @return string
*/ */
public function renderCategoryTree($root = null, public function renderCategoryTree($root = null,
@@ -169,7 +170,8 @@ class HelperCore
$use_radio = false, $use_radio = false,
$use_search = false, $use_search = false,
$disabled_categories = array(), $disabled_categories = array(),
$use_in_popup = false) $use_in_popup = false,
$use_shop_context = false)
{ {
$translations = array( $translations = array(
'selected' => $this->l('selected'), 'selected' => $this->l('selected'),
@@ -229,10 +231,10 @@ class HelperCore
if (!$use_in_popup) if (!$use_in_popup)
$html .= ' $html .= '
$(document).ready(function(){ $(document).ready(function(){
buildTreeView(); buildTreeView('.$use_shop_context.');
});'; });';
else else
$html .= 'buildTreeView();'; $html .= 'buildTreeView('.$use_shop_context.');';
$html .= '</script>'; $html .= '</script>';
$html .= ' $html .= '
+4
View File
@@ -35,6 +35,9 @@ var id_category_root = 0;
function buildTreeView() function buildTreeView()
{ {
use_shop_context = false;
if (buildTreeView.arguments[0])
use_shop_context = true;
$("#categories-treeview").treeview({ $("#categories-treeview").treeview({
url : 'ajax.php', url : 'ajax.php',
toggle: function () { callbackToggle($(this)); }, toggle: function () { callbackToggle($(this)); },
@@ -43,6 +46,7 @@ function buildTreeView()
async: true, async: true,
data: { data: {
getChildrenCategories : true, getChildrenCategories : true,
use_shop_context : use_shop_context,
selectedCat: selectedCat selectedCat: selectedCat
} }
} }