diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index 109b5970a..5a2387647 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -102,24 +102,23 @@ class BlockLayered extends Module Configuration::deleteByName('PS_LAYERED_FILTER_PRICE_USETAX'); Configuration::deleteByName('PS_LAYERED_FILTER_CATEGORY_DEPTH'); - Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_price_index'); - Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_friendly_url'); - Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_attribute_group'); - Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_feature'); - Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value'); - 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'); + Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_price_index'); + Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_friendly_url'); + Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_attribute_group'); + Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_feature'); + Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value'); + 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_product_attribute'); return parent::uninstall(); } private static function installPriceIndexTable() { - Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_price_index`'); + Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_price_index`'); - Db::getInstance()->Execute(' + Db::getInstance()->execute(' CREATE TABLE `'._DB_PREFIX_.'layered_price_index` ( `id_product` INT NOT NULL, `id_currency` INT NOT NULL, @@ -133,8 +132,8 @@ class BlockLayered extends Module private function installFriendlyUrlTable() { - Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_friendly_url`'); - Db::getInstance()->Execute(' + Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_friendly_url`'); + Db::getInstance()->execute(' CREATE TABLE `'._DB_PREFIX_.'layered_friendly_url` ( `id_layered_friendly_url` INT NOT NULL AUTO_INCREMENT, `url_key` varchar(32) NOT NULL, @@ -143,24 +142,24 @@ class BlockLayered extends Module PRIMARY KEY (`id_layered_friendly_url`), INDEX `id_lang` (`id_lang`)) ENGINE = '._MYSQL_ENGINE_); - Db::getInstance()->Execute('CREATE INDEX `url_key` ON `'._DB_PREFIX_.'layered_friendly_url`(url_key(5))'); + Db::getInstance()->execute('CREATE INDEX `url_key` ON `'._DB_PREFIX_.'layered_friendly_url`(url_key(5))'); } private function installIndexableAttributeTable() { // Attributes Groups - Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_group`'); - Db::getInstance()->Execute(' + Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_group`'); + Db::getInstance()->execute(' CREATE TABLE `'._DB_PREFIX_.'layered_indexable_attribute_group` ( `id_attribute_group` INT NOT NULL, `indexable` BOOL NOT NULL DEFAULT 0, PRIMARY KEY (`id_attribute_group`)) ENGINE = '._MYSQL_ENGINE_); - Db::getInstance()->Execute(' + Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'layered_indexable_attribute_group` SELECT id_attribute_group, 1 FROM `'._DB_PREFIX_.'attribute_group`'); - Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_group_lang_value`'); - Db::getInstance()->Execute(' + Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_group_lang_value`'); + Db::getInstance()->execute(' CREATE TABLE `'._DB_PREFIX_.'layered_indexable_attribute_group_lang_value` ( `id_attribute_group` INT NOT NULL, `id_lang` INT NOT NULL, @@ -169,8 +168,8 @@ class BlockLayered extends Module PRIMARY KEY (`id_attribute_group`, `id_lang`)) ENGINE = '._MYSQL_ENGINE_); // Attributes - Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_lang_value`'); - Db::getInstance()->Execute(' + Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_lang_value`'); + Db::getInstance()->execute(' CREATE TABLE `'._DB_PREFIX_.'layered_indexable_attribute_lang_value` ( `id_attribute` INT NOT NULL, `id_lang` INT NOT NULL, @@ -180,19 +179,19 @@ class BlockLayered extends Module // Features - Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature`'); - Db::getInstance()->Execute(' + Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature`'); + Db::getInstance()->execute(' CREATE TABLE `'._DB_PREFIX_.'layered_indexable_feature` ( `id_feature` INT NOT NULL, `indexable` BOOL NOT NULL DEFAULT 0, PRIMARY KEY (`id_feature`)) ENGINE = '._MYSQL_ENGINE_); - Db::getInstance()->Execute(' + Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'layered_indexable_feature` SELECT id_feature, 1 FROM `'._DB_PREFIX_.'feature`'); - Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature_lang_value`'); - Db::getInstance()->Execute(' + Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature_lang_value`'); + Db::getInstance()->execute(' CREATE TABLE `'._DB_PREFIX_.'layered_indexable_feature_lang_value` ( `id_feature` INT NOT NULL, `id_lang` INT NOT NULL, @@ -201,8 +200,8 @@ class BlockLayered extends Module PRIMARY KEY (`id_feature`, `id_lang`)) ENGINE = '._MYSQL_ENGINE_); // Features values - Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature_value_lang_value`'); - Db::getInstance()->Execute(' + Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature_value_lang_value`'); + Db::getInstance()->execute(' CREATE TABLE `'._DB_PREFIX_.'layered_indexable_feature_value_lang_value` ( `id_feature_value` INT NOT NULL, `id_lang` INT NOT NULL, @@ -217,8 +216,8 @@ class BlockLayered extends Module */ public function installProductAttributeTable() { - Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_product_attribute`'); - Db::getInstance()->Execute(' + Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_product_attribute`'); + Db::getInstance()->execute(' CREATE TABLE `'._DB_PREFIX_.'layered_product_attribute` ( `id_attribute` int(10) unsigned NOT NULL, `id_product` int(10) unsigned NOT NULL, @@ -238,7 +237,7 @@ class BlockLayered extends Module else Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_product_attribute WHERE id_product = '.(int)$id_product); - Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'layered_product_attribute` (`id_attribute`, `id_product`, `id_attribute_group`) + Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'layered_product_attribute` (`id_attribute`, `id_product`, `id_attribute_group`) SELECT pac.id_attribute, pa.id_product, ag.id_attribute_group FROM '._DB_PREFIX_.'product_attribute pa INNER JOIN '._DB_PREFIX_.'product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute @@ -258,7 +257,7 @@ class BlockLayered extends Module Db::getInstance()->execute('TRUNCATE '._DB_PREFIX_.'layered_friendly_url'); $attributeValuesByLang = array(); - $filters = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT lc.*, id_lang, name, link_rewrite, cl.id_category + $filters = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT lc.*, id_lang, name, link_rewrite, cl.id_category FROM '._DB_PREFIX_.'layered_category lc INNER JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = lc.id_category AND lc.id_category <> 1 ) GROUP BY type, id_value, id_lang'); @@ -269,7 +268,7 @@ class BlockLayered extends Module switch ($filter['type']) { case 'id_attribute_group': - $attributes = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' + $attributes = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT agl.public_name name, a.id_attribute_group id_name, al.name value, a.id_attribute id_value, al.id_lang, liagl.url_name name_url_name, lial.url_name value_url_name FROM '._DB_PREFIX_.'attribute_group ag @@ -300,7 +299,7 @@ class BlockLayered extends Module break; case 'id_feature': - $features = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' + $features = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT fl.name name, fl.id_feature id_name, fvl.id_feature_value id_value, fvl.value value, fl.id_lang, fl.id_lang, lifl.url_name name_url_name, lifvl.url_name value_url_name FROM '._DB_PREFIX_.'feature_lang fl @@ -330,7 +329,7 @@ class BlockLayered extends Module break; case 'category': - $categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' + $categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT cl.name, cl.id_lang, c.id_category FROM '._DB_PREFIX_.'category c INNER JOIN '._DB_PREFIX_.'category_lang cl ON (c.id_category = cl.id_category) @@ -348,7 +347,7 @@ class BlockLayered extends Module break; case 'manufacturer': - $manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' + $manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT m.name as name,l.id_lang as id_lang, id_manufacturer FROM '._DB_PREFIX_.'manufacturer m , '._DB_PREFIX_.'lang l WHERE l.id_lang = '.(int)$filter['id_lang'].' '); @@ -491,15 +490,15 @@ class BlockLayered extends Module if (!$params['id_feature'] || Tools::getValue('layered_indexable') === false) return; - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature WHERE id_feature = '.(int)$params['id_feature']); - Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_feature VALUES ('.(int)$params['id_feature'].', '.(int)Tools::getValue('layered_indexable').')'); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature WHERE id_feature = '.(int)$params['id_feature']); + Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_feature VALUES ('.(int)$params['id_feature'].', '.(int)Tools::getValue('layered_indexable').')'); - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_lang_value WHERE id_feature = '.(int)$params['id_feature']); // don't care about the id_lang + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_lang_value WHERE id_feature = '.(int)$params['id_feature']); // don't care about the id_lang foreach (Language::getLanguages(false) as $language) { // Data are validated by method "hookPostProcessFeature" $id_lang = (int)$language['id_lang']; - Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_feature_lang_value + Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_feature_lang_value VALUES ('.(int)$params['id_feature'].', '.$id_lang.', \''.pSQL(Tools::link_rewrite(Tools::getValue('url_name_'.$id_lang))).'\', \''.pSQL(Tools::safeOutput(Tools::getValue('meta_title_'.$id_lang), true)).'\')'); } @@ -510,12 +509,12 @@ class BlockLayered extends Module if (!$params['id_feature_value']) return; - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_value_lang_value WHERE id_feature_value = '.(int)$params['id_feature_value']); // don't care about the id_lang + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_value_lang_value WHERE id_feature_value = '.(int)$params['id_feature_value']); // don't care about the id_lang foreach (Language::getLanguages(false) as $language) { // Data are validated by method "hookPostProcessFeatureValue" $id_lang = (int)$language['id_lang']; - Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_feature_value_lang_value + Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_feature_value_lang_value VALUES ('.(int)$params['id_feature_value'].', '.$id_lang.', \''.pSQL(Tools::link_rewrite(Tools::getValue('url_name_'.$id_lang))).'\', \''.pSQL(Tools::safeOutput(Tools::getValue('meta_title_'.$id_lang), true)).'\')'); } @@ -525,7 +524,7 @@ class BlockLayered extends Module { if (!$params['id_feature_value']) return; - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_value_lang_value WHERE id_feature_value = '.(int)$params['id_feature_value']); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_value_lang_value WHERE id_feature_value = '.(int)$params['id_feature_value']); } public function hookPostProcessFeatureValue($params) @@ -547,7 +546,7 @@ class BlockLayered extends Module else $return = ''; - $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS( + $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( 'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_feature_value_lang_value WHERE id_feature_value = '.(int)$params['id_feature_value']); if ($result) @@ -597,12 +596,12 @@ class BlockLayered extends Module if (!$params['id_attribute']) return; - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_lang_value WHERE id_attribute = '.(int)$params['id_attribute']); // don't care about the id_lang + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_lang_value WHERE id_attribute = '.(int)$params['id_attribute']); // don't care about the id_lang foreach (Language::getLanguages(false) as $language) { // Data are validated by method "hookPostProcessAttribute" $id_lang = (int)$language['id_lang']; - Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_attribute_lang_value + Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_attribute_lang_value VALUES ('.(int)$params['id_attribute'].', '.$id_lang.', \''.pSQL(Tools::link_rewrite(Tools::getValue('url_name_'.$id_lang))).'\', \''.pSQL(Tools::safeOutput(Tools::getValue('meta_title_'.$id_lang), true)).'\')'); } @@ -612,7 +611,7 @@ class BlockLayered extends Module { if (!$params['id_attribute']) return; - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_lang_value WHERE id_attribute = '.(int)$params['id_attribute']); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_lang_value WHERE id_attribute = '.(int)$params['id_attribute']); } public function hookPostProcessAttribute($params) @@ -634,7 +633,7 @@ class BlockLayered extends Module else $return = ''; - $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS( + $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( 'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_attribute_lang_value WHERE id_attribute = '.(int)$params['id_attribute']); if ($result) @@ -687,7 +686,7 @@ class BlockLayered extends Module { if (!$params['id_feature']) return; - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature WHERE id_feature = '.(int)$params['id_feature']); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature WHERE id_feature = '.(int)$params['id_feature']); } public function hookAfterSaveAttributeGroup($params) @@ -695,15 +694,15 @@ class BlockLayered extends Module if (!$params['id_attribute_group'] || Tools::getValue('layered_indexable') === false) return; - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group WHERE id_attribute_group = '.(int)$params['id_attribute_group']); - Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_attribute_group VALUES ('.(int)$params['id_attribute_group'].', '.(int)Tools::getValue('layered_indexable').')'); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group WHERE id_attribute_group = '.(int)$params['id_attribute_group']); + Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_attribute_group VALUES ('.(int)$params['id_attribute_group'].', '.(int)Tools::getValue('layered_indexable').')'); - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value WHERE id_attribute_group = '.(int)$params['id_attribute_group']); // don't care about the id_lang + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value WHERE id_attribute_group = '.(int)$params['id_attribute_group']); // don't care about the id_lang foreach (Language::getLanguages(false) as $language) { // Data are validated by method "hookPostProcessAttributeGroup" $id_lang = (int)$language['id_lang']; - Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value + Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value VALUES ('.(int)$params['id_attribute_group'].', '.$id_lang.', \''.pSQL(Tools::link_rewrite(Tools::getValue('url_name_'.$id_lang))).'\', \''.pSQL(Tools::safeOutput(Tools::getValue('meta_title_'.$id_lang), true)).'\')'); } @@ -735,8 +734,8 @@ class BlockLayered extends Module if (!$params['id_attribute_group']) return; - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group WHERE id_attribute_group = '.(int)$params['id_attribute_group']); - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value WHERE id_attribute_group = '.(int)$params['id_attribute_group']); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group WHERE id_attribute_group = '.(int)$params['id_attribute_group']); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value WHERE id_attribute_group = '.(int)$params['id_attribute_group']); } public function hookAttributeGroupForm($params) @@ -747,7 +746,7 @@ class BlockLayered extends Module WHERE id_attribute_group = '.(int)$params['id_attribute_group']); $langValue = array(); - $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS( + $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( 'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value WHERE id_attribute_group = '.(int)$params['id_attribute_group']); if ($result) @@ -820,7 +819,7 @@ class BlockLayered extends Module $indexable = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT indexable FROM '._DB_PREFIX_.'layered_indexable_feature WHERE id_feature = '.(int)$params['id_feature']); $langValue = array(); - $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS( + $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( 'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_feature_lang_value WHERE id_feature = '.(int)$params['id_feature']); if ($result) @@ -983,7 +982,7 @@ class BlockLayered extends Module WHERE `active` = 1 AND psi.id_product is null ORDER by id_product LIMIT 0,'.(int)$length; - foreach (Db::getInstance()->ExecuteS($query) as $product) + foreach (Db::getInstance()->executeS($query) as $product) self::indexProductPrices((int)$product['id_product'], ($smart && $full)); return (int)($cursor + $length); @@ -995,7 +994,7 @@ class BlockLayered extends Module if (is_null($groups)) { - $groups = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT id_group FROM `'._DB_PREFIX_.'group_reduction`'); + $groups = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT id_group FROM `'._DB_PREFIX_.'group_reduction`'); if (!$groups) $groups = array(); } @@ -1039,7 +1038,7 @@ class BlockLayered extends Module else $maxTaxRate = 0; - $productMinPrices = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' + $productMinPrices = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT id_shop, id_currency, id_country, id_group, from_quantity FROM `'._DB_PREFIX_.'specific_price` WHERE id_product = '.(int)$idProduct); @@ -1111,7 +1110,7 @@ class BlockLayered extends Module '.(int)$minPrice[$currency['id_currency']].', '.(int)Tools::ps_round($maxPrice[$currency['id_currency']] * (100 + $maxTaxRate) / 100, 0).')'; - Db::getInstance()->Execute(' + Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'layered_price_index` (id_product, id_currency, id_shop, price_min, price_max) VALUES '.implode(',', $values).' ON DUPLICATE KEY UPDATE id_product = id_product # avoid duplicate keys'); @@ -1213,7 +1212,17 @@ class BlockLayered extends Module public function hookCategoryDeletion($params) { - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_category WHERE id_category = '.(int)$params['category']->id); + $layered_filter_list = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('SELECT * FROM '._DB_PREFIX_.'layered_filter'); + foreach ($layered_filter_list as $layered_filter) + { + $data = unserialize($layered_filter_list['filters']); + if (in_array((int)$params['category']->id, $data['categories'])) + { + unset($data['categories'][array_search((int)$params['category']->id, $data['categories'])]); + Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'layered_filter` SET `filters` = \''.pSQL(serialize($data)).'\''); + } + } + $this->buildLayeredCategories(); } public function getContent() @@ -1235,12 +1244,15 @@ class BlockLayered extends Module else { if (isset($_POST['id_layered_filter']) && $_POST['id_layered_filter']) - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_filter WHERE id_layered_filter = '.(int)Tools::getValue('id_layered_filter')); + { + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_filter WHERE id_layered_filter = '.(int)Tools::getValue('id_layered_filter')); + $this->buildLayeredCategories(); + } if (Tools::getValue('scope') == 1) { - Db::getInstance()->Execute('TRUNCATE TABLE '._DB_PREFIX_.'layered_filter'); - $categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT id_category FROM '._DB_PREFIX_.'category'); + Db::getInstance()->execute('TRUNCATE TABLE '._DB_PREFIX_.'layered_filter'); + $categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT id_category FROM '._DB_PREFIX_.'category'); foreach ($categories as $category) $_POST['categoryBox'][] = (int)$category['id_category']; } @@ -1275,24 +1287,15 @@ class BlockLayered extends Module if (isset($_POST['categoryBox']) && is_array($_POST['categoryBox'])) foreach ($_POST['categoryBox'] as &$categoryBoxTmp) $categoryBoxTmp = (int)$categoryBoxTmp; - - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_category - WHERE - id_category IN ('.implode(',', array_map('intval', $_POST['categoryBox'])).') - AND id_shop IN ('.implode(',', $shop_list).')'); $filterValues = array(); foreach ($_POST['categoryBox'] as $idc) $filterValues['categories'][] = (int)$idc; - - - - $sqlToInsert = 'INSERT INTO '._DB_PREFIX_.'layered_category (id_category, id_shop, id_value, type, position, filter_show_limit, filter_type) VALUES '; + $filterValues['shop_list'] = $shop_list; + $values = false; foreach ($_POST['categoryBox'] as $id_category_layered) { - $n = 0; - foreach ($_POST as $key => $value) if (substr($key, 0, 17) == 'layered_selection' && $value == 'on') { @@ -1308,32 +1311,8 @@ class BlockLayered extends Module 'filter_type' => (int)$type, 'filter_show_limit' => (int)$limit ); - $n++; - foreach ($shop_list as $id_shop) - { - if ($key == 'layered_selection_stock') - $sqlToInsert .= '('.(int)$id_category_layered.', '.(int)$id_shop.', NULL,\'quantity\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; - else if ($key == 'layered_selection_subcategories') - $sqlToInsert .= '('.(int)$id_category_layered.', '.(int)$id_shop.', NULL,\'category\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; - else if ($key == 'layered_selection_condition') - $sqlToInsert .= '('.(int)$id_category_layered.', '.(int)$id_shop.', NULL,\'condition\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; - else if ($key == 'layered_selection_weight_slider') - $sqlToInsert .= '('.(int)$id_category_layered.', '.(int)$id_shop.', NULL,\'weight\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; - else if ($key == 'layered_selection_price_slider') - $sqlToInsert .= '('.(int)$id_category_layered.', '.(int)$id_shop.', NULL,\'price\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; - else if ($key == 'layered_selection_manufacturer') - $sqlToInsert .= '('.(int)$id_category_layered.', '.(int)$id_shop.', NULL,\'manufacturer\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; - else if (substr($key, 0, 21) == 'layered_selection_ag_') - $sqlToInsert .= '('.(int)$id_category_layered.', '.(int)$id_shop.', '.(int)str_replace('layered_selection_ag_', '', $key).', - \'id_attribute_group\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; - else if (substr($key, 0, 23) == 'layered_selection_feat_') - $sqlToInsert .= '('.(int)$id_category_layered.', '.(int)$id_shop.', '.(int)str_replace('layered_selection_feat_', '', $key).', - \'id_feature\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; - } } } - if ($values) - Db::getInstance()->Execute(rtrim($sqlToInsert, ',')); $valuesToInsert = array( 'name' => pSQL(Tools::getValue('layered_tpl_name')), @@ -1344,16 +1323,7 @@ class BlockLayered extends Module $valuesToInsert['id_layered_filter'] = (int)Tools::getValue('id_layered_filter'); Db::getInstance()->autoExecute(_DB_PREFIX_.'layered_filter', $valuesToInsert, 'INSERT'); - - 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'].')'); - } + $this->buildLayeredCategories(); $html .= '
').
$this->l('Your filter').' "'.Tools::safeOutput(Tools::getValue('layered_tpl_name')).'" '.
@@ -1383,7 +1353,8 @@ class BlockLayered extends Module
if ($layeredValues)
{
- Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_filter WHERE id_layered_filter = '.(int)$_GET['id_layered_filter'].' LIMIT 1');
+ Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_filter WHERE id_layered_filter = '.(int)$_GET['id_layered_filter'].' LIMIT 1');
+ $this->buildLayeredCategories();
$html .= '
').'
@@ -1422,7 +1393,7 @@ class BlockLayered extends Module
';
$categoryList = array();
- foreach (Db::getInstance()->ExecuteS('SELECT id_category FROM `'._DB_PREFIX_.'category`') as $category)
+ foreach (Db::getInstance()->executeS('SELECT id_category FROM `'._DB_PREFIX_.'category`') as $category)
if ($category['id_category'] != 1)
$categoryList[] = $category['id_category'];
@@ -1582,7 +1553,7 @@ class BlockLayered extends Module