[*] BO : categories multishop improved
This commit is contained in:
@@ -28,27 +28,20 @@
|
|||||||
|
|
||||||
{block name=leadin}
|
{block name=leadin}
|
||||||
<div class="cat_bar2">
|
<div class="cat_bar2">
|
||||||
{if count($categories_tree) == 0}
|
{assign var=i value=0}
|
||||||
{if $category_root->id_category == 0}
|
{foreach $categories_tree key=key item=category}
|
||||||
<img src="../img/admin/home.gif" alt="" /> {$category_root->name}
|
{if $i++ == 0}
|
||||||
|
<img src="../img/admin/home.gif" alt="" />
|
||||||
|
{assign var=params_url value=""}
|
||||||
{else}
|
{else}
|
||||||
<img src="../img/admin/home.gif" alt="" /> {$categories_name}
|
{assign var=params_url value="&id_category={$category.id_category}&viewcategory"}
|
||||||
{/if}
|
{/if}
|
||||||
{else}
|
{if $key == 0}
|
||||||
{if $category_root->id_category == 0}
|
{$category.name}
|
||||||
<a href="{$currentIndex}&token={$token}"><img src="../img/admin/home.gif" alt="" /> {$category_root->name}</a> >
|
|
||||||
{else}
|
{else}
|
||||||
<a href="{$currentIndex}&id_category={$category_root->id_category}&token={$token}"><img src="../img/admin/home.gif" alt="" /> {$category_root->name}</a> >
|
<a href="{$currentIndex}{$params_url}&token={$token}">{$category.name}</a> >
|
||||||
{/if}
|
{/if}
|
||||||
|
{/foreach}
|
||||||
{foreach $categories_tree key=key item=category}
|
|
||||||
{if $key == 0}
|
|
||||||
{$category.name}
|
|
||||||
{else}
|
|
||||||
<a href="{$currentIndex}&token={$token}&id_category={$category.id_category}&viewcategory">{$category.name}</a> >
|
|
||||||
{/if}
|
|
||||||
{/foreach}
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
{if isset($delete_category) && $delete_category}
|
{if isset($delete_category) && $delete_category}
|
||||||
<form action="{$REQUEST_URI}" method="post">
|
<form action="{$REQUEST_URI}" method="post">
|
||||||
|
|||||||
+34
-24
@@ -390,19 +390,21 @@ class CategoryCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function regenerateEntireNtree()
|
public static function regenerateEntireNtree()
|
||||||
{
|
{
|
||||||
$categories = Db::getInstance()->executeS('SELECT id_category, id_parent FROM '._DB_PREFIX_.'category ORDER BY id_category ASC');
|
$categories = Db::getInstance()->executeS('SELECT id_category, id_parent FROM '._DB_PREFIX_.'category ORDER BY id_parent, position ASC');
|
||||||
$categories_array = array();
|
$categories_array = array();
|
||||||
foreach ($categories as $category)
|
foreach ($categories as $category)
|
||||||
$categories_array[(int)$category['id_parent']]['subcategories'][(int)$category['id_category']] = 1;
|
$categories_array[$category['id_parent']]['subcategories'][] = $category['id_category'];
|
||||||
$n = 1;
|
$n = 1;
|
||||||
Category::_subTree($categories_array, 1, $n);
|
|
||||||
|
if (isset($categories_array[0]) && $categories_array[0]['subcategories'])
|
||||||
|
Category::_subTree($categories_array, $categories_array[0]['subcategories'][0], $n);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function _subTree(&$categories, $id_category, &$n)
|
protected static function _subTree(&$categories, $id_category, &$n)
|
||||||
{
|
{
|
||||||
$left = (int)$n++;
|
$left = $n++;
|
||||||
if (isset($categories[(int)$id_category]['subcategories']))
|
if (isset($categories[(int)$id_category]['subcategories']))
|
||||||
foreach (array_keys($categories[(int)$id_category]['subcategories']) as $id_subcategory)
|
foreach ($categories[(int)$id_category]['subcategories'] as $id_subcategory)
|
||||||
Category::_subTree($categories, (int)$id_subcategory, $n);
|
Category::_subTree($categories, (int)$id_subcategory, $n);
|
||||||
$right = (int)$n++;
|
$right = (int)$n++;
|
||||||
|
|
||||||
@@ -660,7 +662,7 @@ class CategoryCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function getHomeCategories($id_lang, $active = true)
|
public static function getHomeCategories($id_lang, $active = true)
|
||||||
{
|
{
|
||||||
return Category::getChildren(1, $id_lang, $active);
|
return self::getChildren(1, $id_lang, $active);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRootCategory($id_lang = null, Shop $shop = null)
|
public static function getRootCategory($id_lang = null, Shop $shop = null)
|
||||||
@@ -671,17 +673,13 @@ class CategoryCore extends ObjectModel
|
|||||||
if (!$shop)
|
if (!$shop)
|
||||||
$shop = $context->shop;
|
$shop = $context->shop;
|
||||||
|
|
||||||
// context : no multishop
|
$is_more_than_one_root_category = count(Category::getCategoriesWithoutParent()) > 1;
|
||||||
if (count(Shop::getShops()) == 1)
|
if ((!Shop::isFeatureActive() && $is_more_than_one_root_category) ||
|
||||||
if (count(Category::getCategoriesWithoutParent()) > 1)
|
Shop::isFeatureActive() && $is_more_than_one_root_category && $context->shop() != Shop::CONTEXT_SHOP)
|
||||||
$category = new Category();
|
$category = Category::getTopCategory();
|
||||||
else
|
else
|
||||||
$category = new Category($shop->getCategory(), $id_lang);
|
$category = new Category($shop->getCategory(), $id_lang);
|
||||||
else // context : multishop
|
|
||||||
if (count(Category::getCategoriesWithoutParent()) > 1 && $context->shop() != Shop::CONTEXT_SHOP)
|
|
||||||
$category = new Category();
|
|
||||||
else
|
|
||||||
$category = new Category($shop->getCategory(), $id_lang);
|
|
||||||
return $category;
|
return $category;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -932,17 +930,20 @@ class CategoryCore extends ObjectModel
|
|||||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||||
ON (c.`id_category` = cl.`id_category`
|
ON (c.`id_category` = cl.`id_category`
|
||||||
AND `id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').')';
|
AND `id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').')';
|
||||||
if (count(Shop::getShops()) > 1 && $context->shop() == Shop::CONTEXT_SHOP)
|
if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP)
|
||||||
$sql .= '
|
$sql .= '
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs
|
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs
|
||||||
ON c.`id_category` = cs.`id_category`';
|
ON c.`id_category` = cs.`id_category`';
|
||||||
$sql .= '
|
$sql .= '
|
||||||
WHERE c.`id_category` = '.(int)$id_current;
|
WHERE c.`id_category` = '.(int)$id_current;
|
||||||
if (count(Shop::getShops()) > 1 && $context->shop() == Shop::CONTEXT_SHOP)
|
if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP)
|
||||||
$sql .= '
|
$sql .= '
|
||||||
AND cs.`id_shop` = '.(int)$context->shop->getID(true);
|
AND cs.`id_shop` = '.(int)$context->shop->getID(true);
|
||||||
$root_category = Category::getRootCategory();
|
$root_category = Category::getRootCategory();
|
||||||
if ($context->shop() == Shop::CONTEXT_SHOP && (!Tools::isSubmit('id_category') || (int)Tools::getValue('id_category') == (int)$root_category->id_category || (int)$root_category->id_category == (int)$context->shop->id_category))
|
if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP &&
|
||||||
|
(!Tools::isSubmit('id_category') ||
|
||||||
|
(int)Tools::getValue('id_category') == (int)$root_category->id_category ||
|
||||||
|
(int)$root_category->id_category == (int)$context->shop->id_category))
|
||||||
$sql .= '
|
$sql .= '
|
||||||
AND c.`id_parent` != 0';
|
AND c.`id_parent` != 0';
|
||||||
|
|
||||||
@@ -952,7 +953,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)
|
if (!$result || ($result[0]['id_category'] == $context->shop->id_category && Shop::isFeatureActive()))
|
||||||
return $categories;
|
return $categories;
|
||||||
$id_current = $result[0]['id_parent'];
|
$id_current = $result[0]['id_parent'];
|
||||||
}
|
}
|
||||||
@@ -1317,7 +1318,7 @@ class CategoryCore extends ObjectModel
|
|||||||
SELECT DISTINCT c.*
|
SELECT DISTINCT c.*
|
||||||
FROM `'._DB_PREFIX_.'category` 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.')
|
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
|
WHERE `level_depth` = 1
|
||||||
');
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1328,5 +1329,14 @@ class CategoryCore extends ObjectModel
|
|||||||
FROM `'._DB_PREFIX_.'shop`
|
FROM `'._DB_PREFIX_.'shop`
|
||||||
WHERE `id_category` = '.(int)$this->id);
|
WHERE `id_category` = '.(int)$this->id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public static function getTopCategory()
|
||||||
|
{
|
||||||
|
$id_category = Db::getInstance()->getValue('
|
||||||
|
SELECT `id_category`
|
||||||
|
FROM `'._DB_PREFIX_.'category`
|
||||||
|
WHERE `id_parent` = 0
|
||||||
|
');
|
||||||
|
return new Category($id_category);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+4
-1
@@ -973,7 +973,9 @@ class ToolsCore
|
|||||||
if ($categoryType === 'products')
|
if ($categoryType === 'products')
|
||||||
{
|
{
|
||||||
$interval = Category::getInterval($id_category);
|
$interval = Category::getInterval($id_category);
|
||||||
$intervalRoot = Category::getInterval($context->shop->getCategory());
|
$id_root_category = $context->shop->getCategory();
|
||||||
|
$root_category = new Category($id_root_category);
|
||||||
|
$intervalRoot = Category::getInterval($id_root_category);
|
||||||
if ($interval)
|
if ($interval)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT c.id_category, cl.name, cl.link_rewrite
|
$sql = 'SELECT c.id_category, cl.name, cl.link_rewrite
|
||||||
@@ -985,6 +987,7 @@ class ToolsCore
|
|||||||
AND c.nright <= '.$intervalRoot['nright'].'
|
AND c.nright <= '.$intervalRoot['nright'].'
|
||||||
AND cl.id_lang = '.(int)$context->language->id.'
|
AND cl.id_lang = '.(int)$context->language->id.'
|
||||||
AND c.active = 1
|
AND c.active = 1
|
||||||
|
AND c.level_depth > '.(int)$root_category->level_depth.'
|
||||||
ORDER BY c.level_depth ASC';
|
ORDER BY c.level_depth ASC';
|
||||||
$categories = Db::getInstance()->executeS($sql);
|
$categories = Db::getInstance()->executeS($sql);
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,10 @@ class AdminCategoriesControllerCore extends AdminController
|
|||||||
if (($id_category = Tools::getvalue('id_category')) && $this->action != 'select_delete')
|
if (($id_category = Tools::getvalue('id_category')) && $this->action != 'select_delete')
|
||||||
$this->_category = new Category($id_category);
|
$this->_category = new Category($id_category);
|
||||||
else
|
else
|
||||||
$this->_category = new Category($this->context->shop->id_category);
|
if (Shop::isFeatureActive() && $this->context->shop() == Shop::CONTEXT_SHOP)
|
||||||
|
$this->_category = new Category($this->context->shop->id_category);
|
||||||
|
else
|
||||||
|
$this->_category = Category::getTopCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initContent()
|
public function initContent()
|
||||||
@@ -123,22 +126,22 @@ class AdminCategoriesControllerCore extends AdminController
|
|||||||
$this->addRowAction('view');
|
$this->addRowAction('view');
|
||||||
|
|
||||||
$count_categories_without_parent = count(Category::getCategoriesWithoutParent());
|
$count_categories_without_parent = count(Category::getCategoriesWithoutParent());
|
||||||
$nb_shop = count(Shop::getShops());
|
$is_multishop = Shop::isFeatureActive();
|
||||||
if (Tools::isSubmit('id_category'))
|
if (Tools::isSubmit('id_category'))
|
||||||
$id_parent = $this->_category->id;
|
$id_parent = $this->_category->id;
|
||||||
else if ($nb_shop == 1 && $count_categories_without_parent > 1)
|
else if (!$is_multishop && $count_categories_without_parent > 1)
|
||||||
$id_parent = 0;
|
$id_parent = 1;
|
||||||
else if ($nb_shop > 1 && $count_categories_without_parent == 1)
|
else if ($is_multishop && $count_categories_without_parent == 1)
|
||||||
|
$id_parent = 2;
|
||||||
|
else if ($is_multishop && $count_categories_without_parent > 1 && $this->context->shop() != Shop::CONTEXT_SHOP)
|
||||||
$id_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
|
else
|
||||||
$id_parent = $this->context->shop->id_category;
|
$id_parent = $this->context->shop->id_category;
|
||||||
|
|
||||||
$this->_filter .= ' AND `id_parent` = '.(int)$id_parent.' ';
|
$this->_filter .= ' AND `id_parent` = '.(int)$id_parent.' ';
|
||||||
$this->_select = 'position ';
|
$this->_select = 'position ';
|
||||||
// we add restriction for shop
|
// we add restriction for shop
|
||||||
if (Shop::CONTEXT_SHOP == Context::getContext()->shop() && $nb_shop > 1)
|
if (Shop::CONTEXT_SHOP == Context::getContext()->shop() && $is_multishop)
|
||||||
{
|
{
|
||||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON a.`id_category` = cs.`id_category`';
|
$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);
|
$this->_where = ' AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true);
|
||||||
@@ -147,29 +150,11 @@ class AdminCategoriesControllerCore extends AdminController
|
|||||||
$categories_tree = $this->_category->getParentsCategories();
|
$categories_tree = $this->_category->getParentsCategories();
|
||||||
if (empty($categories_tree)
|
if (empty($categories_tree)
|
||||||
&& ($this->_category->id_category != 1 || Tools::isSubmit('id_category'))
|
&& ($this->_category->id_category != 1 || Tools::isSubmit('id_category'))
|
||||||
&& (Shop::CONTEXT_SHOP == Context::getContext()->shop() && $nb_shop == 1 && $count_categories_without_parent > 1))
|
&& (Shop::CONTEXT_SHOP == Context::getContext()->shop() && !$is_multishop && $count_categories_without_parent > 1))
|
||||||
$categories_tree = array(array('name' => $this->_category->name[$this->context->language->id]));
|
$categories_tree = array(array('name' => $this->_category->name[$this->context->language->id]));
|
||||||
|
|
||||||
asort($categories_tree);
|
asort($categories_tree);
|
||||||
if ($nb_shop == 1 && $count_categories_without_parent > 1)
|
|
||||||
$categories_name = $this->l('Root');
|
|
||||||
else
|
|
||||||
if ($this->_category->getName() == '')
|
|
||||||
{
|
|
||||||
$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))
|
|
||||||
{
|
|
||||||
$root->name = $this->l('Root');
|
|
||||||
$root->id = $root->id_category = 0;
|
|
||||||
}
|
|
||||||
$this->tpl_list_vars['categories_tree'] = $categories_tree;
|
$this->tpl_list_vars['categories_tree'] = $categories_tree;
|
||||||
$this->tpl_list_vars['categories_name'] = $categories_name;
|
|
||||||
$this->tpl_list_vars['category_root'] = $root;
|
|
||||||
|
|
||||||
if (Tools::isSubmit('submitBulkdelete'.$this->table) OR Tools::isSubmit('delete'.$this->table))
|
if (Tools::isSubmit('submitBulkdelete'.$this->table) OR Tools::isSubmit('delete'.$this->table))
|
||||||
$this->tpl_list_vars['delete_category'] = true;
|
$this->tpl_list_vars['delete_category'] = true;
|
||||||
@@ -271,10 +256,7 @@ class AdminCategoriesControllerCore extends AdminController
|
|||||||
$guest_group_information = sprintf($this->l('%s - Customer who placed an order with the Guest Checkout.'), "<b>".$guest->name[$this->context->language->id]."</b>");
|
$guest_group_information = sprintf($this->l('%s - Customer who placed an order with the Guest Checkout.'), "<b>".$guest->name[$this->context->language->id]."</b>");
|
||||||
$default_group_information = sprintf($this->l('%s - All persons who created an account on this site.'), "<b>".$default->name[$this->context->language->id]."</b>");
|
$default_group_information = sprintf($this->l('%s - All persons who created an account on this site.'), "<b>".$default->name[$this->context->language->id]."</b>");
|
||||||
$root_category = Category::getRootCategory();
|
$root_category = Category::getRootCategory();
|
||||||
if (!$root_category->id_category)
|
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name[$this->context->language->id]);
|
||||||
$root_category = array('id_category' => '0', 'name' => $this->l('Root'));
|
|
||||||
else
|
|
||||||
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name);
|
|
||||||
$this->fields_form = array(
|
$this->fields_form = array(
|
||||||
'tinymce' => true,
|
'tinymce' => true,
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
@@ -451,10 +433,7 @@ class AdminCategoriesControllerCore extends AdminController
|
|||||||
$id_parent = (int)Tools::getValue('id_parent');
|
$id_parent = (int)Tools::getValue('id_parent');
|
||||||
// if true, we are in a root category creation
|
// if true, we are in a root category creation
|
||||||
if (!$id_parent && !Tools::isSubmit('is_root_category'))
|
if (!$id_parent && !Tools::isSubmit('is_root_category'))
|
||||||
{
|
$_POST['is_root_category'] = $_POST['level_depth'] = $_POST['id_parent'] = $id_parent = 1;
|
||||||
$_POST['id_parent'] = $id_parent = 0;
|
|
||||||
$_POST['is_root_category'] = 1;
|
|
||||||
}
|
|
||||||
if ($id_category)
|
if ($id_category)
|
||||||
{
|
{
|
||||||
if ($id_category != $id_parent)
|
if ($id_category != $id_parent)
|
||||||
|
|||||||
@@ -247,13 +247,8 @@ class AdminGroupsControllerCore extends AdminController
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ($this->context->shop() == Shop::CONTEXT_SHOP)
|
$root_category = Category::getRootCategory();
|
||||||
{
|
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name[$this->context->language->id]);
|
||||||
$root_category = Category::getRootCategory();
|
|
||||||
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$root_category = array('id_category' => '0', 'name' => $this->l('Root'));
|
|
||||||
$this->fields_value['reduction'] = isset($group->reduction) ? $group->reduction : 0;
|
$this->fields_value['reduction'] = isset($group->reduction) ? $group->reduction : 0;
|
||||||
|
|
||||||
$trads = array(
|
$trads = array(
|
||||||
|
|||||||
@@ -2472,12 +2472,7 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
$selected_cat = Product::getProductCategoriesFull($product->id, $this->default_form_language);
|
$selected_cat = Product::getProductCategoriesFull($product->id, $this->default_form_language);
|
||||||
}
|
}
|
||||||
$root_category = Category::getRootCategory();
|
$root_category = Category::getRootCategory();
|
||||||
if (!$root_category->id_category)
|
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name[$this->context->language->id]);
|
||||||
{
|
|
||||||
$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(
|
$translations = array(
|
||||||
'Root' => $root_category,
|
'Root' => $root_category,
|
||||||
'selected' => $this->l('selected'),
|
'selected' => $this->l('selected'),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<field name="active"/>
|
<field name="active"/>
|
||||||
</fields>
|
</fields>
|
||||||
<entities>
|
<entities>
|
||||||
<category id="Home" id_parent="" active="1" is_root_category="1"/>
|
<category id="Root" id_parent="" active="1"/>
|
||||||
|
<category id="Home" id_parent="Root" active="1" is_root_category="1"/>
|
||||||
</entities>
|
</entities>
|
||||||
</entity_category>
|
</entity_category>
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<entity_category>
|
<entity_category>
|
||||||
|
<category id="Root" id_shop="1">
|
||||||
|
<name>Root</name>
|
||||||
|
<description/>
|
||||||
|
<link_rewrite>root</link_rewrite>
|
||||||
|
<meta_title/>
|
||||||
|
<meta_keywords/>
|
||||||
|
<meta_description/>
|
||||||
|
</category>
|
||||||
<category id="Home" id_shop="1">
|
<category id="Home" id_shop="1">
|
||||||
<name>Start</name>
|
<name>Start</name>
|
||||||
<description/>
|
<description/>
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<entity_category>
|
<entity_category>
|
||||||
|
<category id="Root" id_shop="1">
|
||||||
|
<name>Root</name>
|
||||||
|
<description/>
|
||||||
|
<link_rewrite>root</link_rewrite>
|
||||||
|
<meta_title/>
|
||||||
|
<meta_keywords/>
|
||||||
|
<meta_description/>
|
||||||
|
</category>
|
||||||
<category id="Home" id_shop="1">
|
<category id="Home" id_shop="1">
|
||||||
<name>Home</name>
|
<name>Home</name>
|
||||||
<description/>
|
<description/>
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<entity_category>
|
<entity_category>
|
||||||
|
<category id="Root" id_shop="1">
|
||||||
|
<name>Root</name>
|
||||||
|
<description/>
|
||||||
|
<link_rewrite>root</link_rewrite>
|
||||||
|
<meta_title/>
|
||||||
|
<meta_keywords/>
|
||||||
|
<meta_description/>
|
||||||
|
</category>
|
||||||
<category id="Home" id_shop="1">
|
<category id="Home" id_shop="1">
|
||||||
<name>Inicio</name>
|
<name>Inicio</name>
|
||||||
<description/>
|
<description/>
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<entity_category>
|
<entity_category>
|
||||||
|
<category id="Root" id_shop="1">
|
||||||
|
<name>Root</name>
|
||||||
|
<description/>
|
||||||
|
<link_rewrite>root</link_rewrite>
|
||||||
|
<meta_title/>
|
||||||
|
<meta_keywords/>
|
||||||
|
<meta_description/>
|
||||||
|
</category>
|
||||||
<category id="Home" id_shop="1">
|
<category id="Home" id_shop="1">
|
||||||
<name>Accueil</name>
|
<name>Accueil</name>
|
||||||
<description/>
|
<description/>
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<entity_category>
|
<entity_category>
|
||||||
|
<category id="Root" id_shop="1">
|
||||||
|
<name>Root</name>
|
||||||
|
<description/>
|
||||||
|
<link_rewrite>root</link_rewrite>
|
||||||
|
<meta_title/>
|
||||||
|
<meta_keywords/>
|
||||||
|
<meta_description/>
|
||||||
|
</category>
|
||||||
<category id="Home" id_shop="1">
|
<category id="Home" id_shop="1">
|
||||||
<name>Home page</name>
|
<name>Home page</name>
|
||||||
<description/>
|
<description/>
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ class InstallModelInstall extends InstallAbstractModel
|
|||||||
$shop = new Shop();
|
$shop = new Shop();
|
||||||
$shop->active = true;
|
$shop->active = true;
|
||||||
$shop->id_group_shop = $group_shop->id;
|
$shop->id_group_shop = $group_shop->id;
|
||||||
$shop->id_category = 1;
|
$shop->id_category = 2;
|
||||||
$shop->id_theme = 1;
|
$shop->id_theme = 1;
|
||||||
$shop->name = 'Default';
|
$shop->name = 'Default';
|
||||||
if (!$shop->add())
|
if (!$shop->add())
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function generate_root_category_for_multishop()
|
||||||
|
{
|
||||||
|
Db::getInstance()->execute('
|
||||||
|
UPDATE `'._DB_PREFIX_.'category` SET `level_depth`=`level_depth`+1
|
||||||
|
');
|
||||||
|
|
||||||
|
Db::getInstance()->execute('
|
||||||
|
INSERT INTO `'._DB_PREFIX_.'category` (`id_parent`, `level_depth`, `active`, `date_add`, `date_upd`, `is_root_category`) VALUES
|
||||||
|
(0, 0, 1, NOW(), NOW(), 0)
|
||||||
|
');
|
||||||
|
$id = Db::getInstance()->Insert_ID();
|
||||||
|
|
||||||
|
$langs = Db::getInstance()->executeS('
|
||||||
|
SELECT `id_lang`
|
||||||
|
FROM `'._DB_PREFIX_.'lang`
|
||||||
|
');
|
||||||
|
|
||||||
|
$shops = Db::getInstance()->executeS('
|
||||||
|
SELECT `id_shop`
|
||||||
|
FROM `'._DB_PREFIX_.'shop`
|
||||||
|
');
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
foreach ($langs as $lang)
|
||||||
|
foreach ($shops as $shop)
|
||||||
|
$data[] = array(
|
||||||
|
'id_lang' => $lang['id_lang'],
|
||||||
|
'id_shop' => $shop['id_shop'],
|
||||||
|
'id_category' => $id,
|
||||||
|
'name' => 'Root',
|
||||||
|
'link_rewrite' => '',
|
||||||
|
);
|
||||||
|
Db::getInstance()->autoExecute(_DB_PREFIX_.'category_lang', $data, 'INSERT');
|
||||||
|
|
||||||
|
Db::getInstance()->execute('
|
||||||
|
UPDATE `'._DB_PREFIX_.'category`
|
||||||
|
SET `id_parent` = '.(int)$id.'
|
||||||
|
WHERE `id_parent` = 0 AND `id_category` <> '.(int)$id.'
|
||||||
|
');
|
||||||
|
|
||||||
|
Category::regenerateEntireNtree();
|
||||||
|
}
|
||||||
@@ -18,3 +18,14 @@ WHERE `name` = "order fenced" AND (`id_lang` = 1 OR `id_lang` = 3 OR `id_lang` =
|
|||||||
UPDATE `PREFIX_supply_order_state_lang`
|
UPDATE `PREFIX_supply_order_state_lang`
|
||||||
SET `name` = "Commande cloturée"
|
SET `name` = "Commande cloturée"
|
||||||
WHERE `name` = "order fenced" AND id_lang = 2;
|
WHERE `name` = "order fenced" AND id_lang = 2;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `PREFIX_category_shop` (
|
||||||
|
`id_category` int(11) NOT NULL,
|
||||||
|
`id_shop` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id_category`, `id_shop`),
|
||||||
|
UNIQUE KEY `id_category_shop` (`id_category`,`id_shop`)
|
||||||
|
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
/* PHP:generate_root_category_for_multishop(); */;
|
||||||
Reference in New Issue
Block a user