diff --git a/classes/Product.php b/classes/Product.php index e9c9eda2a..28da3c03a 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -1957,7 +1957,7 @@ class ProductCore extends ObjectModel */ public function getPrice($tax = true, $id_product_attribute = NULL, $decimals = 6, $divisor = NULL, $only_reduc = false, $usereduc = true, $quantity = 1) { - return self::getPriceStatic((int)($this->id), $tax, $id_product_attribute, $decimals, $divisor, $only_reduc, $usereduc, $quantity); + return Product::getPriceStatic((int)($this->id), $tax, $id_product_attribute, $decimals, $divisor, $only_reduc, $usereduc, $quantity); } public function getIdProductAttributeMostExpensive() @@ -1975,7 +1975,7 @@ class ProductCore extends ObjectModel public function getPriceWithoutReduct($notax = false, $id_product_attribute = false) { - return self::getPriceStatic((int)($this->id), !$notax, $id_product_attribute, 6, NULL, false, false); + return Product::getPriceStatic((int)($this->id), !$notax, $id_product_attribute, 6, NULL, false, false); } /** diff --git a/install-dev/classes/ToolsInstall.php b/install-dev/classes/ToolsInstall.php index 389ed74d1..f75a71604 100644 --- a/install-dev/classes/ToolsInstall.php +++ b/install-dev/classes/ToolsInstall.php @@ -66,7 +66,7 @@ class ToolsInstall !isset($_GET['name']) OR empty($_GET['name']) OR !Validate::isUnixName($_GET['name']), !isset($_GET['login']) OR empty($_GET['login']) OR !Validate::isUnixName($_GET['login']), !isset($_GET['password']), - !isset($_GET['tablePrefix']) OR !Validate::isTablePrefix($_GET['tablePrefix']), + (!isset($_GET['tablePrefix']) OR !Validate::isTablePrefix($_GET['tablePrefix'])) && !empty($_GET['tablePrefix']), ); foreach ($data_check AS $data) diff --git a/install-dev/controller.js b/install-dev/controller.js index 69dab95a9..6ba94a371 100644 --- a/install-dev/controller.js +++ b/install-dev/controller.js @@ -372,7 +372,7 @@ function verifyDbAccess () +"&password="+encodeURIComponent($("#dbPassword").val()) +"&engine="+$("#dbEngine option:selected").val() + "&name=" + $("#dbName").val() - + "&tablePrefix=" + $("#db_prefix").val(), + + "&tablePrefix=" + encodeURIComponent($("#db_prefix").val()), success: function(ret) { ret = ret.getElementsByTagName('action')[0]; diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index 72d8e81e6..a843fe1e3 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -49,15 +49,14 @@ class BlockLayered extends Module public function install() { - if ($this->registerHook('leftColumn') && $this->registerHook('header') && $this->registerHook('footer') + if (parent::install() && $this->registerHook('leftColumn') && $this->registerHook('header') && $this->registerHook('footer') && $this->registerHook('categoryAddition') && $this->registerHook('categoryUpdate') && $this->registerHook('attributeGroupForm') && $this->registerHook('afterSaveAttributeGroup') && $this->registerHook('afterDeleteAttributeGroup') && $this->registerHook('featureForm') && $this->registerHook('afterDeleteFeature') && $this->registerHook('afterSaveFeature') && $this->registerHook('categoryDeletion') && $this->registerHook('afterSaveProduct') && $this->registerHook('productListAssign') && $this->registerHook('postProcessAttributeGroup') && $this->registerHook('postProcessFeature') && $this->registerHook('featureValueForm') && $this->registerHook('postProcessFeatureValue') && $this->registerHook('afterDeleteFeatureValue') && $this->registerHook('afterSaveFeatureValue') && $this->registerHook('attributeForm') - && $this->registerHook('postProcessAttribute') && $this->registerHook('afterDeleteAttribute') && $this->registerHook('afterSaveAttribute') - && parent::install()) + && $this->registerHook('postProcessAttribute') && $this->registerHook('afterDeleteAttribute') && $this->registerHook('afterSaveAttribute')) { Configuration::updateValue('PS_LAYERED_HIDE_0_VALUES', 0); Configuration::updateValue('PS_LAYERED_SHOW_QTIES', 1); @@ -65,24 +64,32 @@ class BlockLayered extends Module $this->rebuildLayeredStructure(); $this->rebuildLayeredCache(); self::_installPriceIndexTable(); - self::_installFriendlyUrlTable(); - self::_installIndexableAttributeTable(); - self::_installProductAttributeTable(); + $this->_installFriendlyUrlTable(); + $this->_installIndexableAttributeTable(); + $this->_installProductAttributeTable(); $this->indexUrl(); $this->indexAttribute(); + + if(Db::getInstance()->getValue('SELECT count(*) FROM `'._DB_PREFIX_.'product`') < 10000) // Lock price indexation if too many products self::fullIndexProcess(); return true; } + else + { + // Installation failed (or hook registration) => uninstall the module + $this->uninstall(); return false; } + } public function uninstall() { /* Delete all configurations */ Configuration::deleteByName('PS_LAYERED_HIDE_0_VALUES'); Configuration::deleteByName('PS_LAYERED_SHOW_QTIES'); + Configuration::deleteByName('PS_LAYERED_INDEXED'); Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_price_index'); Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_friendly_url'); @@ -96,7 +103,7 @@ class BlockLayered extends Module return parent::uninstall(); } - private function _installPriceIndexTable() + private static function _installPriceIndexTable() { Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_price_index`'); @@ -986,7 +993,8 @@ class BlockLayered extends Module Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'layered_price_index` (id_product, id_currency, price_min, price_max) - VALUES '.implode(',', $values)); + VALUES '.implode(',', $values).' + ON DUPLICATE KEY UPDATE id_product = id_product # avoid duplicate keys'); } public function hookLeftColumn($params)