// categories multishop improvements (BO breadcrumb + category tree root removed)
This commit is contained in:
@@ -671,8 +671,10 @@ class CategoryCore extends ObjectModel
|
|||||||
if (is_null($id_lang))
|
if (is_null($id_lang))
|
||||||
$id_lang = $context->language->id;
|
$id_lang = $context->language->id;
|
||||||
if (!$shop)
|
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;
|
$is_more_than_one_root_category = count(Category::getCategoriesWithoutParent()) > 1;
|
||||||
if ((!Shop::isFeatureActive() && $is_more_than_one_root_category) ||
|
if ((!Shop::isFeatureActive() && $is_more_than_one_root_category) ||
|
||||||
Shop::isFeatureActive() && $is_more_than_one_root_category && $context->shop() != Shop::CONTEXT_SHOP)
|
Shop::isFeatureActive() && $is_more_than_one_root_category && $context->shop() != Shop::CONTEXT_SHOP)
|
||||||
@@ -922,6 +924,7 @@ class CategoryCore extends ObjectModel
|
|||||||
|
|
||||||
$categories = null;
|
$categories = null;
|
||||||
$id_current = $this->id;
|
$id_current = $this->id;
|
||||||
|
$context->shop = ($context->shop->id) ? $context->shop : new Shop(Configuration::get('PS_DEFAULT_SHOP'));
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
$sql = '
|
$sql = '
|
||||||
@@ -953,7 +956,7 @@ class CategoryCore extends ObjectModel
|
|||||||
$categories[] = $result[0];
|
$categories[] = $result[0];
|
||||||
else if (!$categories)
|
else if (!$categories)
|
||||||
$categories = array();
|
$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;
|
return $categories;
|
||||||
$id_current = $result[0]['id_parent'];
|
$id_current = $result[0]['id_parent'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,11 +164,11 @@ class HelperCore
|
|||||||
'search' => $this->l('Find a category')
|
'search' => $this->l('Find a category')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$top_category = Category::getTopCategory();
|
||||||
|
$root_category = Category::getRootCategory();
|
||||||
|
$disabled_categories[] = $top_category->id;
|
||||||
if (!$root)
|
if (!$root)
|
||||||
{
|
|
||||||
$root_category = Category::getRootCategory();
|
|
||||||
$root = array('name' => $root_category->name, 'id_category' => $root_category->id);
|
$root = array('name' => $root_category->name, 'id_category' => $root_category->id);
|
||||||
}
|
|
||||||
|
|
||||||
if (!$use_radio)
|
if (!$use_radio)
|
||||||
$input_name = $input_name.'[]';
|
$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 .= '
|
$html .= '
|
||||||
<ul id="categories-treeview" class="filetree">
|
<ul id="categories-treeview" class="filetree">
|
||||||
<li id="'.$root['id_category'].'" class="hasChildren">
|
<li id="'.$root['id_category'].'" class="hasChildren">
|
||||||
<span class="folder">
|
<span class="folder">'.$root_input.' </span>
|
||||||
<input type="'.(!$use_radio ? 'checkbox' : 'radio').'" name="'
|
|
||||||
.$input_name.'" value="'.$root['id_category'].'" '
|
|
||||||
.($home_is_selected ? 'checked' : '').' onclick="clickOnCategoryBox($(this));" /> '
|
|
||||||
.$root['name']
|
|
||||||
.'</span>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><span class="placeholder"> </span></li>
|
<li><span class="placeholder"> </span></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -95,8 +95,10 @@ class AdminCategoriesControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
if (Shop::isFeatureActive() && $this->context->shop() == Shop::CONTEXT_SHOP)
|
if (Shop::isFeatureActive() && $this->context->shop() == Shop::CONTEXT_SHOP)
|
||||||
$this->_category = new Category($this->context->shop->id_category);
|
$this->_category = new Category($this->context->shop->id_category);
|
||||||
else
|
else if (count(Category::getCategoriesWithoutParent()) > 1)
|
||||||
$this->_category = Category::getTopCategory();
|
$this->_category = Category::getTopCategory();
|
||||||
|
else
|
||||||
|
$this->_category = new Category(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initContent()
|
public function initContent()
|
||||||
@@ -131,11 +133,11 @@ class AdminCategoriesControllerCore extends AdminController
|
|||||||
if (Tools::isSubmit('id_category'))
|
if (Tools::isSubmit('id_category'))
|
||||||
$id_parent = $this->_category->id;
|
$id_parent = $this->_category->id;
|
||||||
else if (!$is_multishop && $count_categories_without_parent > 1)
|
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)
|
else if ($is_multishop && $count_categories_without_parent == 1)
|
||||||
$id_parent = 2; //TODO need to get the ID category where category = Home
|
$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)
|
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
|
else
|
||||||
$id_parent = $this->context->shop->id_category;
|
$id_parent = $this->context->shop->id_category;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user