[*] BO : categories multishop improved

This commit is contained in:
vChabot
2012-01-19 14:03:33 +00:00
parent 9d41358764
commit 585b670df3
15 changed files with 163 additions and 92 deletions
+2 -1
View File
@@ -5,6 +5,7 @@
<field name="active"/>
</fields>
<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>
</entity_category>
+8
View File
@@ -1,5 +1,13 @@
<?xml version="1.0"?>
<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">
<name>Start</name>
<description/>
+8
View File
@@ -1,5 +1,13 @@
<?xml version="1.0"?>
<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">
<name>Home</name>
<description/>
+8
View File
@@ -1,5 +1,13 @@
<?xml version="1.0"?>
<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">
<name>Inicio</name>
<description/>
+8
View File
@@ -1,5 +1,13 @@
<?xml version="1.0"?>
<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">
<name>Accueil</name>
<description/>
+8
View File
@@ -1,5 +1,13 @@
<?xml version="1.0"?>
<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">
<name>Home page</name>
<description/>
+1 -1
View File
@@ -219,7 +219,7 @@ class InstallModelInstall extends InstallAbstractModel
$shop = new Shop();
$shop->active = true;
$shop->id_group_shop = $group_shop->id;
$shop->id_category = 1;
$shop->id_category = 2;
$shop->id_theme = 1;
$shop->name = 'Default';
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();
}
+11
View File
@@ -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`
SET `name` = "Commande cloturée"
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(); */;