// little fix about categories with multishop and Helper::renderAdminCategorieTree
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12301 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1292,7 +1292,7 @@ class CategoryCore extends ObjectModel
|
||||
public static function getCategoriesWithoutParent()
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT c.*
|
||||
SELECT DISTINCT c.*
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE `id_parent` = 0
|
||||
|
||||
@@ -116,12 +116,17 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
$id_parent = $this->_category->id;
|
||||
else if ($nb_shop == 1 && $count_categories_without_parent > 1)
|
||||
$id_parent = 0;
|
||||
else if ($nb_shop > 1 && $count_categories_without_parent == 1)
|
||||
$id_parent = 1;
|
||||
else if ($nb_shop > 1 && $count_categories_without_parent > 1 && $this->context->shop() != Shop::CONTEXT_SHOP)
|
||||
$id_parent = 0;
|
||||
else
|
||||
$id_parent = $this->context->shop->id_category;
|
||||
|
||||
$this->_filter .= ' AND `id_parent` = '.(int)$id_parent.' ';
|
||||
$this->_select = 'position ';
|
||||
// we add restriction for shop
|
||||
if (Shop::CONTEXT_ALL == Context::getContext()->shop())
|
||||
if (Shop::CONTEXT_SHOP == Context::getContext()->shop() && $nb_shop > 1)
|
||||
{
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON a.`id_category` = cs.`id_category`';
|
||||
$this->_where = ' AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true);
|
||||
@@ -137,7 +142,13 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
if ($nb_shop == 1 && $count_categories_without_parent > 1)
|
||||
$categories_name = $this->l('Root');
|
||||
else
|
||||
$categories_name = stripslashes($this->_category->getName());
|
||||
if (empty($categories_name))
|
||||
{
|
||||
$categories_name = new Category($id_parent);
|
||||
$categories_name = stripslashes($categories_name->getName());
|
||||
}
|
||||
else
|
||||
$categories_name = stripslashes($this->_category->getName());
|
||||
$root = Category::getRootCategory();
|
||||
if (!is_array($root->name) && empty($root->name))
|
||||
{
|
||||
|
||||
@@ -2511,9 +2511,15 @@ class AdminProductsControllerCore extends AdminController
|
||||
else
|
||||
$selected_cat = Product::getProductCategoriesFull($product->id, $this->default_form_language);
|
||||
}
|
||||
|
||||
$root_category = Category::getRootCategory();
|
||||
if (!$root_category->id_category)
|
||||
{
|
||||
$root_category->id_category = 0;
|
||||
$root_category->name = $this->l('Root');
|
||||
}
|
||||
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name);
|
||||
$translations = array(
|
||||
'Home' => $this->l('Home'),
|
||||
'Root' => $root_category,
|
||||
'selected' => $this->l('selected'),
|
||||
'Collapse All' => $this->l('Collapse All'),
|
||||
'Expand All' => $this->l('Expand All'),
|
||||
|
||||
@@ -238,8 +238,15 @@ class AdminScenesControllerCore extends AdminController
|
||||
foreach (Scene::getIndexedCategories($obj->id) as $k => $row)
|
||||
$selected_cat[] = $row['id_category'];
|
||||
|
||||
$root_category = Category::getRootCategory();
|
||||
if (!$root_category->id_category)
|
||||
{
|
||||
$root_category->id_category = 0;
|
||||
$root_category->name = $this->l('Root');
|
||||
}
|
||||
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name);
|
||||
$trads = array(
|
||||
'Home' => $this->l('Home'),
|
||||
'Root' => $root_category,
|
||||
'selected' => $this->l('selected'),
|
||||
'Check all' => $this->l('Check all'),
|
||||
'Check All' => $this->l('Check All'),
|
||||
|
||||
@@ -491,10 +491,11 @@ class AdminShopControllerCore extends AdminController
|
||||
public function initCategoriesAssociation($id_root = 1)
|
||||
{
|
||||
$id_shop = Tools::getValue('id_shop');
|
||||
$shop = new Shop($id_shop);
|
||||
$selected_cat = Shop::getCategories($id_shop);
|
||||
|
||||
if ($this->context->shop() == Shop::CONTEXT_SHOP && Tools::isSubmit('id_shop'))
|
||||
$root_category = new Category($id_shop);
|
||||
$root_category = new Category($shop->id_category);
|
||||
else
|
||||
$root_category = new Category($id_root);
|
||||
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name[$this->context->language->id]);
|
||||
|
||||
Reference in New Issue
Block a user