// categories multishop improvements (BO breadcrumb + category tree root removed)

This commit is contained in:
vChabot
2012-01-23 14:50:47 +00:00
parent 7cbaf711be
commit 1e8d84fd0d
3 changed files with 23 additions and 15 deletions
+6 -3
View File
@@ -671,8 +671,10 @@ class CategoryCore extends ObjectModel
if (is_null($id_lang))
$id_lang = $context->language->id;
if (!$shop)
$shop = $context->shop;
if (Shop::isFeatureActive() && $context->shop() != Shop::CONTEXT_SHOP)
$shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
else
$shop = $context->shop;
$is_more_than_one_root_category = count(Category::getCategoriesWithoutParent()) > 1;
if ((!Shop::isFeatureActive() && $is_more_than_one_root_category) ||
Shop::isFeatureActive() && $is_more_than_one_root_category && $context->shop() != Shop::CONTEXT_SHOP)
@@ -922,6 +924,7 @@ class CategoryCore extends ObjectModel
$categories = null;
$id_current = $this->id;
$context->shop = ($context->shop->id) ? $context->shop : new Shop(Configuration::get('PS_DEFAULT_SHOP'));
while (true)
{
$sql = '
@@ -953,7 +956,7 @@ class CategoryCore extends ObjectModel
$categories[] = $result[0];
else if (!$categories)
$categories = array();
if (!$result || ($result[0]['id_category'] == $context->shop->id_category && Shop::isFeatureActive()))
if (!$result || ($result[0]['id_category'] == $context->shop->id_category))
return $categories;
$id_current = $result[0]['id_parent'];
}
+12 -9
View File
@@ -164,11 +164,11 @@ class HelperCore
'search' => $this->l('Find a category')
);
$top_category = Category::getTopCategory();
$root_category = Category::getRootCategory();
$disabled_categories[] = $top_category->id;
if (!$root)
{
$root_category = Category::getRootCategory();
$root = array('name' => $root_category->name, 'id_category' => $root_category->id);
}
if (!$use_radio)
$input_name = $input_name.'[]';
@@ -243,15 +243,18 @@ class HelperCore
}
}
$root_input = ' ';
if ($root_category->id != $top_category->id)
$root_input = '<input type="'.(!$use_radio ? 'checkbox' : 'radio').'" name="'
.$input_name.'" value="'.$root['id_category'].'" '
.($home_is_selected ? 'checked' : '').' onclick="clickOnCategoryBox($(this));" />
<span class="category_label">'
.$root['name'].
'</span>';
$html .= '
<ul id="categories-treeview" class="filetree">
<li id="'.$root['id_category'].'" class="hasChildren">
<span class="folder">
<input type="'.(!$use_radio ? 'checkbox' : 'radio').'" name="'
.$input_name.'" value="'.$root['id_category'].'" '
.($home_is_selected ? 'checked' : '').' onclick="clickOnCategoryBox($(this));" /> '
.$root['name']
.'</span>
<span class="folder">'.$root_input.' </span>
<ul>
<li><span class="placeholder">&nbsp;</span></li>
</ul>
@@ -95,8 +95,10 @@ class AdminCategoriesControllerCore extends AdminController
else
if (Shop::isFeatureActive() && $this->context->shop() == Shop::CONTEXT_SHOP)
$this->_category = new Category($this->context->shop->id_category);
else
else if (count(Category::getCategoriesWithoutParent()) > 1)
$this->_category = Category::getTopCategory();
else
$this->_category = new Category(2);
}
public function initContent()
@@ -131,11 +133,11 @@ class AdminCategoriesControllerCore extends AdminController
if (Tools::isSubmit('id_category'))
$id_parent = $this->_category->id;
else if (!$is_multishop && $count_categories_without_parent > 1)
$id_parent = $top_category;
$id_parent = $top_category->id;
else if ($is_multishop && $count_categories_without_parent == 1)
$id_parent = 2; //TODO need to get the ID category where category = Home
else if ($is_multishop && $count_categories_without_parent > 1 && $this->context->shop() != Shop::CONTEXT_SHOP)
$id_parent = $top_category;
$id_parent = $top_category->id;
else
$id_parent = $this->context->shop->id_category;