From 455f13e996208e4c15ebbdfe04827ba0240711c2 Mon Sep 17 00:00:00 2001 From: dMetzger Date: Tue, 14 Aug 2012 14:10:11 +0000 Subject: [PATCH] // Perfs and clean --- classes/Hook.php | 6 +++--- classes/Product.php | 3 +-- install-dev/data/db_structure.sql | 1 + install-dev/upgrade/sql/1.5.0.16.sql | 2 ++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/classes/Hook.php b/classes/Hook.php index aa60ded02..c4835e838 100644 --- a/classes/Hook.php +++ b/classes/Hook.php @@ -260,15 +260,15 @@ class HookCore extends ObjectModel // For payment modules, we check that they are available in the contextual country if (Validate::isLoadedObject($context->country)) $sql->where('(h.name != "displayPayment" OR (SELECT id_country FROM '._DB_PREFIX_.'module_country mc WHERE mc.id_module = m.id_module AND id_country = '.(int)$context->country->id.' LIMIT 1) = '.(int)$context->country->id.')'); - $sql->where('hm.id_shop IN('.implode(', ', $shop_list).')'); + $sql->where('hm.id_shop IN ('.implode(', ', $shop_list).')'); if (isset($context->customer) && $context->customer->isLogged()) { $sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`'); - $sql->where('mg.`id_group` IN('.implode(', ', $groups).')'); + $sql->where('mg.`id_group` IN ('.implode(', ', $groups).')'); + $sql->groupBy('hm.id_hook, hm.id_module'); } - $sql->groupBy('hm.id_hook, hm.id_module'); $sql->orderBy('hm.`position`'); // Store results per hook name diff --git a/classes/Product.php b/classes/Product.php index cc83e0061..1d9a667bb 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -1874,9 +1874,8 @@ class ProductCore extends ObjectModel if (Combination::isFeatureActive()) { $sql->select('pa.id_product_attribute'); - $sql->leftOuterJoin('product_attribute', 'pa', 'p.`id_product` = pa.`id_product`'); + $sql->leftOuterJoin('product_attribute', 'pa', 'p.`id_product` = pa.`id_product` AND pa.default_on = 1'); $sql->join(Shop::addSqlAssociation('product_attribute', 'pa', false)); - $sql->where('(product_attribute_shop.default_on = 1 OR product_attribute_shop.default_on IS NULL)'); } $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); diff --git a/install-dev/data/db_structure.sql b/install-dev/data/db_structure.sql index 336a5a2f0..e303476e5 100644 --- a/install-dev/data/db_structure.sql +++ b/install-dev/data/db_structure.sql @@ -1870,6 +1870,7 @@ CREATE TABLE `PREFIX_tax_rule` ( PRIMARY KEY (`id_tax_rule`), KEY `id_tax_rules_group` (`id_tax_rules_group`), KEY `id_tax` (`id_tax`) + KEY `category_getproducts` ( `id_tax_rules_group` , `id_country` , `id_state` , `zipcode_from` ) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; CREATE TABLE `PREFIX_tax_rules_group` ( diff --git a/install-dev/upgrade/sql/1.5.0.16.sql b/install-dev/upgrade/sql/1.5.0.16.sql index 66d2e8fcb..96346250d 100644 --- a/install-dev/upgrade/sql/1.5.0.16.sql +++ b/install-dev/upgrade/sql/1.5.0.16.sql @@ -11,3 +11,5 @@ DELETE FROM `PREFIX_tab_lang` WHERE `id_tab` NOT IN (SELECT `id_tab` FROM `PREFI DELETE FROM `PREFIX_access` WHERE `id_tab` NOT IN (SELECT `id_tab` FROM `PREFIX_tab`); UPDATE `PREFIX_employee` SET bo_theme = 'default'; + +ALTER TABLE `PREFIX_tax_rule` ADD INDEX `category_getproducts` ( `id_tax_rules_group` , `id_country` , `id_state` , `zipcode_from` )