From bde26d52b44b9d8e25c2cf30bd1df4d0fbf30799 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Wed, 28 Mar 2012 12:37:06 +0000 Subject: [PATCH] // Blocklayered: Fix bug with blocklayered and multishop git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14327 b9a71923-0436-4b27-9f14-aed3839534dd --- modules/blocklayered/blocklayered.php | 30 ++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index 85cb8a7d4..0ab87b71a 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -120,6 +120,7 @@ class BlockLayered extends Module Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_feature_lang_value'); Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_category'); Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_filter'); + Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_filter_shop'); Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_product_attribute'); return parent::uninstall(); } @@ -1414,6 +1415,16 @@ class BlockLayered extends Module } } + + if (version_compare(_PS_VERSION_,'1.5','>')) + { + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_filter_shop WHERE `id_layered_filter` = '.(int)$id_layered_filter); + if (isset($assos)) + foreach ($assos as $asso) + Db::getInstance()->execute('INSERT INTO layered_filter_shop (`id_layered_filter`, `id_shop`) + VALUES('.$id_layered_filter.', '.(int)$asso['id_shop'].')'); + } + $values_to_insert = array( 'name' => pSQL(Tools::getValue('layered_tpl_name')), 'filters' => pSQL(serialize($filter_values)), @@ -3698,7 +3709,7 @@ class BlockLayered extends Module $helper->id = (int)$id_layered_filter; $helper->table = 'layered_filter'; $helper->identifier = 'id_layered_filter'; - $helper->base_folder = Tools::getValue('base_folder').'/themes/template/'; + $helper->base_folder = Tools::getValue('base_folder').'/themes/default/template/helpers/form/'; $html .= '
'.$helper->renderAssoShop().'
@@ -3817,6 +3828,13 @@ class BlockLayered extends Module `filters` TEXT NULL, `n_categories` INT(10) UNSIGNED NOT NULL, `date_add` DATETIME NOT NULL)'); + + Db::getInstance()->execute(' + CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'layered_filter_shop` ( + `id_layered_filter` INT(10) UNSIGNED NOT NULL, + `id_shop` INT(11) UNSIGNED NOT NULL, + PRIMARY KEY (`id_layered_filter`, `id_shop`), + KEY `id_shop` (`id_shop`))'); } public function rebuildLayeredCache($products_ids = array(), $categories_ids = array()) @@ -3958,6 +3976,16 @@ class BlockLayered extends Module { Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'layered_filter(name, filters, n_categories, date_add) VALUES (\''.$this->l('My template').' '.date('Y-m-d').'\', \''.pSQL(serialize($filter_data)).'\', '.count($filter_data['categories']).', NOW())'); + + if (version_compare(_PS_VERSION_,'1.5','>')) + { + $last_id = Db::getInstance()->Insert_ID(); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_filter_shop WHERE `id_layered_filter` = '.$last_id); + foreach ($shop_list as $id_shop) + Db::getInstance()->execute('INSERT INTO layered_filter_shop (`id_layered_filter`, `id_shop`) + VALUES('.$last_id.', '.(int)$id_shop.')'); + } + $this->buildLayeredCategories(); } }