From 42cdc988ac7e1dfeda5e42f8879f7380d147627d Mon Sep 17 00:00:00 2001 From: ha99y Date: Thu, 19 Sep 2013 22:15:00 -0700 Subject: [PATCH 1/3] Send noindex header to avoid ghost carts by bots --- controllers/front/CartController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index cc98424c9..a209e7958 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -52,6 +52,9 @@ class CartControllerCore extends FrontController { parent::init(); + // Send noindex to avoid ghost carts by bots + header("X-Robots-Tag: noindex, nofollow", true); + // Get page main parameters $this->id_product = (int)Tools::getValue('id_product', null); $this->id_product_attribute = (int)Tools::getValue('id_product_attribute', Tools::getValue('ipa')); From eb6600e840fc78b03e07df7974da1682038c400f Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Thu, 19 Sep 2013 09:36:10 +0200 Subject: [PATCH 2/3] // Blockcustomerprivacy should not be installed by default --- install-dev/models/install.php | 1 - 1 file changed, 1 deletion(-) diff --git a/install-dev/models/install.php b/install-dev/models/install.php index 00008c856..149a42029 100644 --- a/install-dev/models/install.php +++ b/install-dev/models/install.php @@ -520,7 +520,6 @@ class InstallModelInstall extends InstallAbstractModel 'blockcontact', 'blockcontactinfos', 'blockcurrencies', - 'blockcustomerprivacy', 'blocklanguages', 'blockmanufacturer', 'blockmyaccount', From f8ca06d9272f794a35cc6ab9ec6d1d2bf8b657de Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Fri, 20 Sep 2013 10:26:43 +0200 Subject: [PATCH 3/3] // Better cache depth management for smarty --- classes/Currency.php | 21 ++++++++++++++++++++- classes/module/Module.php | 21 ++++++++++++--------- modules/blockcurrencies/blockcurrencies.php | 2 +- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/classes/Currency.php b/classes/Currency.php index 6740dd955..bf9cca614 100644 --- a/classes/Currency.php +++ b/classes/Currency.php @@ -81,6 +81,7 @@ class CurrencyCore extends ObjectModel /** @var array Currency cache */ static protected $currencies = array(); + protected static $countActiveCurrencies = array(); protected $webserviceParameters = array( 'objectsNodeName' => 'currencies', @@ -414,5 +415,23 @@ class CurrencyCore extends ObjectModel self::$currencies[(int)($id)] = new Currency($id); return self::$currencies[(int)($id)]; } -} + + public static function countActiveCurrencies($id_shop = null) + { + if ($id_shop === null) + $id_shop = (int)Context::getContext()->shop->id; + if (!isset(self::$countActiveCurrencies[$id_shop])) + self::$countActiveCurrencies[$id_shop] = Db::getInstance()->getValue(' + SELECT COUNT(DISTINCT c.id_currency) FROM `'._DB_PREFIX_.'currency` c + LEFT JOIN '._DB_PREFIX_.'currency_shop cs ON (cs.id_currency = c.id_currency AND cs.id_shop = '.(int)$id_shop.') + WHERE c.`active` = 1 + '); + return self::$countActiveCurrencies[$id_shop]; + } + + public static function isMultiCurrencyActivated($id_shop = null) + { + return (Currency::countActiveCurrencies($id_shop) > 1); + } +} \ No newline at end of file diff --git a/classes/module/Module.php b/classes/module/Module.php index 79ec715c1..4e86ca7ba 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -1630,15 +1630,18 @@ abstract class ModuleCore protected function getCacheId($name = null) { - $cache_array = array( - $name !== null ? $name : $this->name, - (int)Tools::usingSecureMode(), - (int)$this->context->shop->id, - (int)Group::getCurrent()->id, - (int)$this->context->language->id, - (int)$this->context->currency->id, - (int)$this->context->country->id - ); + $cache_array = array(); + $cache_array[] = $name !== null ? $name : $this->name; + if (Configuration::get('PS_SSL_ENABLED')) + $cache_array[] = (int)Tools::usingSecureMode(); + if (Shop::isFeatureActive()) + $cache_array[] = (int)$this->context->shop->id; + $cache_array[] = (int)Group::getCurrent()->id; + if (Language::isMultiLanguageActivated()) + $cache_array[] = (int)$this->context->language->id; + if (Currency::isMultiCurrencyActivated()) + $cache_array[] = (int)$this->context->currency->id; + $cache_array[] = (int)$this->context->country->id; return implode('|', $cache_array); } diff --git a/modules/blockcurrencies/blockcurrencies.php b/modules/blockcurrencies/blockcurrencies.php index 2841b1dd5..34eda8b86 100644 --- a/modules/blockcurrencies/blockcurrencies.php +++ b/modules/blockcurrencies/blockcurrencies.php @@ -53,7 +53,7 @@ class BlockCurrencies extends Module if (Configuration::get('PS_CATALOG_MODE')) return false; - if (!count(Currency::getCurrencies())) + if (!Currency::isMultiCurrencyActivated()) return false; $this->smarty->assign('blockcurrencies_sign', $this->context->currency->sign);