diff --git a/admin-dev/themes/default/css/modules.css b/admin-dev/themes/default/css/modules.css
index 59eb3f29c..4db7804bd 100644
--- a/admin-dev/themes/default/css/modules.css
+++ b/admin-dev/themes/default/css/modules.css
@@ -34,7 +34,7 @@
.toolbarBox .process-icon-new-module { background-image: url('../img/process-icon-new-module.png')}
.toolbarBox .process-icon-new-module-addon { background-image: url('../img/process-icon-new-module-addon.png')}
-div.fix-toolbar {border-bottom: 1px solid #E0E0E0;position:fixed;top:0;opacity:0.9;z-index:1}
+div.fix-toolbar {border-bottom: 1px solid #E0E0E0;position:fixed;top:0;opacity:0.9;z-index:11}
/*FILTER MODULE*/
diff --git a/admin-dev/themes/default/template/controllers/groups/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/groups/helpers/form/form.tpl
index 242ea2e22..d73c9cc69 100644
--- a/admin-dev/themes/default/template/controllers/groups/helpers/form/form.tpl
+++ b/admin-dev/themes/default/template/controllers/groups/helpers/form/form.tpl
@@ -138,7 +138,7 @@
}
else
{
- $('#group_discount_category_table').append('
{$category.path}
- {l s='Discount: %d%%' sprintf=$category.reduction}
+ {l s='Discount: %.2f%%' sprintf=$category.reduction}
diff --git a/admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl b/admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl
index 96908c212..6762c700c 100755
--- a/admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl
+++ b/admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl
@@ -30,7 +30,7 @@
{l s='Name:'} {$group->name[$language->id]}
- {l s='Discount: %d%%' sprintf=$group->reduction}
+ {l s='Discount: %.2f%%' sprintf=$group->reduction}
{l s='Current category discount:'}
{if !$categorieReductions}
{l s='None'}
@@ -39,7 +39,7 @@
{foreach $categorieReductions key=key item=category }
{$category.path}
- {l s='Discount: %d%%' sprintf=$category.reduction}
+ {l s='Discount: %.2f%%' sprintf=$category.reduction}
{/foreach}
diff --git a/admin-dev/themes/default/template/controllers/modules/js.tpl b/admin-dev/themes/default/template/controllers/modules/js.tpl
index d920b668b..8bfa5fa12 100644
--- a/admin-dev/themes/default/template/controllers/modules/js.tpl
+++ b/admin-dev/themes/default/template/controllers/modules/js.tpl
@@ -87,7 +87,7 @@
});
// Method to check / uncheck all modules checkbox
- $('#checkme').click(function()
+ $('#moduleContainer').on("click", "#checkme", function()
{
if ($(this).attr("rel") == 'false')
{
@@ -321,8 +321,8 @@
catch(e){}
return false;
});
-
- $('.toggle_favorite').live('click', function(event)
+
+ $('#moduleContainer').on("click", ".toggle_favorite", function()
{
var el = $(this);
var value_pref = el.data('value');
diff --git a/admin-dev/themes/default/template/helpers/form/form.tpl b/admin-dev/themes/default/template/helpers/form/form.tpl
index 8d53a000c..6c8b10f62 100644
--- a/admin-dev/themes/default/template/helpers/form/form.tpl
+++ b/admin-dev/themes/default/template/helpers/form/form.tpl
@@ -236,7 +236,7 @@
{if isset($fields_value[$input.name].image) && $fields_value[$input.name].image}
{$fields_value[$input.name].image}
-
{l s='File size'} {$fields_value[$input.name].size}kb
+
{l s='File size'} {$fields_value[$input.name].size}{l s='kb'}
{l s='Delete'}
diff --git a/admin-dev/themes/default/template/helpers/list/list_content.tpl b/admin-dev/themes/default/template/helpers/list/list_content.tpl
index ae80d9d10..c54d68607 100644
--- a/admin-dev/themes/default/template/helpers/list/list_content.tpl
+++ b/admin-dev/themes/default/template/helpers/list/list_content.tpl
@@ -49,6 +49,7 @@
{/if}
class="{if !$no_link}pointer{/if}
{if isset($params.position) && $order_by == 'position' && $order_way != 'DESC'} dragHandle{/if}
+ {if isset($params.class)} {$params.class}{/if}
{if isset($params.align)} {$params.align}{/if}"
{if (!isset($params.position) && !$no_link && !isset($params.remove_onclick))}
onclick="document.location = '{$current_index}&{$identifier}={$tr.$identifier}{if $view}&view{else}&update{/if}{$table}&token={$token}'">
diff --git a/classes/Address.php b/classes/Address.php
index 10600c1cf..f74697445 100644
--- a/classes/Address.php
+++ b/classes/Address.php
@@ -264,13 +264,17 @@ class AddressCore extends ObjectModel
if(!isset($id_address) || empty($id_address))
return false;
- if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
- SELECT c.`active`
- FROM `'._DB_PREFIX_.'address` a
- LEFT JOIN `'._DB_PREFIX_.'country` c ON c.`id_country` = a.`id_country`
- WHERE a.`id_address` = '.(int)$id_address))
- return false;
- return ($result['active']);
+ $cache_id = 'Address::isCountryActiveById_'.(int)$id_address;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getvalue('
+ SELECT c.`active`
+ FROM `'._DB_PREFIX_.'address` a
+ LEFT JOIN `'._DB_PREFIX_.'country` c ON c.`id_country` = a.`id_country`
+ WHERE a.`id_address` = '.(int)$id_address);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -324,12 +328,17 @@ class AddressCore extends ObjectModel
{
if (!$id_customer)
return false;
-
- return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
- SELECT `id_address`
- FROM `'._DB_PREFIX_.'address`
- WHERE `id_customer` = '.(int)$id_customer.' AND `deleted` = 0'.($active ? ' AND `active` = 1' : '')
- );
+ $cache_id = 'Address::getFirstCustomerAddressId_'.(int)$id_customer.'-'.(bool)$active;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
+ SELECT `id_address`
+ FROM `'._DB_PREFIX_.'address`
+ WHERE `id_customer` = '.(int)$id_customer.' AND `deleted` = 0'.($active ? ' AND `active` = 1' : '')
+ );
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -379,5 +388,4 @@ class AddressCore extends ObjectModel
$query->where('id_warehouse = 0');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
}
-}
-
+}
\ No newline at end of file
diff --git a/classes/CMS.php b/classes/CMS.php
index 13b7cac0b..ee2f28d30 100644
--- a/classes/CMS.php
+++ b/classes/CMS.php
@@ -190,7 +190,7 @@ class CMSCore extends ObjectModel
return (Db::getInstance()->getValue($sql));
}
- public static function getCMSPages($id_lang = null, $id_cms_category = null, $active = true)
+ public static function getCMSPages($id_lang = null, $id_cms_category = null, $active = true, $id_shop = null)
{
$sql = new DbQuery();
$sql->select('*');
@@ -198,6 +198,9 @@ class CMSCore extends ObjectModel
if ($id_lang)
$sql->innerJoin('cms_lang', 'l', 'c.id_cms = l.id_cms AND l.id_lang = '.(int)$id_lang);
+ if ($id_shop)
+ $sql->innerJoin('cms_shop', 'cs', 'c.id_cms = cs.id_cms AND cs.id_shop = '.(int)$id_shop);
+
if ($active)
$sql->where('c.active = 1');
diff --git a/classes/Carrier.php b/classes/Carrier.php
index 6de5899aa..726bac6c0 100644
--- a/classes/Carrier.php
+++ b/classes/Carrier.php
@@ -277,17 +277,20 @@ class CarrierCore extends ObjectModel
public function getMaxDeliveryPriceByWeight($id_zone)
{
- $sql = 'SELECT d.`price`
- FROM `'._DB_PREFIX_.'delivery` d
- INNER JOIN `'._DB_PREFIX_.'range_weight` w ON d.`id_range_weight` = w.`id_range_weight`
- WHERE d.`id_zone` = '.(int)$id_zone.'
- AND d.`id_carrier` = '.(int)$this->id.'
- '.Carrier::sqlDeliveryRangeShop('range_weight').'
- ORDER BY w.`delimiter2` DESC LIMIT 1';
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
- if (!isset($result[0]['price']))
- return false;
- return $result[0]['price'];
+ $cache_id = 'Carrier::getMaxDeliveryPriceByWeight_'.(int)$this->id.'-'.(int)$id_zone;
+ if (!Cache::isStored($cache_id))
+ {
+ $sql = 'SELECT d.`price`
+ FROM `'._DB_PREFIX_.'delivery` d
+ INNER JOIN `'._DB_PREFIX_.'range_weight` w ON d.`id_range_weight` = w.`id_range_weight`
+ WHERE d.`id_zone` = '.(int)$id_zone.'
+ AND d.`id_carrier` = '.(int)$this->id.'
+ '.Carrier::sqlDeliveryRangeShop('range_weight').'
+ ORDER BY w.`delimiter2` DESC';
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -357,17 +360,20 @@ class CarrierCore extends ObjectModel
public function getMaxDeliveryPriceByPrice($id_zone)
{
- $sql = 'SELECT d.`price`
- FROM `'._DB_PREFIX_.'delivery` d
- INNER JOIN `'._DB_PREFIX_.'range_price` r ON d.`id_range_price` = r.`id_range_price`
- WHERE d.`id_zone` = '.(int)$id_zone.'
- AND d.`id_carrier` = '.(int)$this->id.'
- '.Carrier::sqlDeliveryRangeShop('range_price').'
- ORDER BY r.`delimiter2` DESC LIMIT 1';
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
- if (!isset($result[0]['price']))
- return false;
- return $result[0]['price'];
+ $cache_id = 'Carrier::getMaxDeliveryPriceByPrice_'.(int)$this->id.'-'.(int)$id_zone;
+ if (!Cache::isStored($cache_id))
+ {
+ $sql = 'SELECT d.`price`
+ FROM `'._DB_PREFIX_.'delivery` d
+ INNER JOIN `'._DB_PREFIX_.'range_price` r ON d.`id_range_price` = r.`id_range_price`
+ WHERE d.`id_zone` = '.(int)$id_zone.'
+ AND d.`id_carrier` = '.(int)$this->id.'
+ '.Carrier::sqlDeliveryRangeShop('range_price').'
+ ORDER BY r.`delimiter2` DESC';
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -449,7 +455,13 @@ class CarrierCore extends ObjectModel
GROUP BY c.`id_carrier`
ORDER BY c.`position` ASC';
- $carriers = Db::getInstance()->executeS($sql);
+ $cache_id = 'Carrier::getCarriers_'.md5($sql);
+ if (!Cache::isStored($cache_id))
+ {
+ $carriers = Db::getInstance()->executeS($sql);
+ Cache::store($cache_id, $carriers);
+ }
+ $carriers = Cache::retrieve($cache_id);
if (is_array($carriers) && count($carriers))
{
@@ -1199,7 +1211,14 @@ class CarrierCore extends ObjectModel
$query->where('pc.id_product = '.(int)$product->id);
$query->where('pc.id_shop = '.(int)$id_shop);
- $carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
+ $cache_id = 'Carrier::getAvailableCarrierList_'.(int)$product->id.'-'.(int)$id_shop;
+ if (!Cache::isStored($cache_id))
+ {
+ $carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
+ Cache::store($cache_id, $carriers_for_product);
+ }
+ $carriers_for_product = Cache::retrieve($cache_id);
+
$carrier_list = array();
if (!empty($carriers_for_product))
{
diff --git a/classes/Cart.php b/classes/Cart.php
index f38015171..681a1e93a 100644
--- a/classes/Cart.php
+++ b/classes/Cart.php
@@ -325,7 +325,7 @@ class CartCore extends ObjectModel
if (!CartRule::isFeatureActive() || !$this->id)
return array();
- $cache_key = 'Cart::getCartRules'.$this->id.'-'.$filter;
+ $cache_key = 'Cart::getCartRules_'.$this->id.'-'.$filter;
if (!Cache::isStored($cache_key))
{
$result = Db::getInstance()->executeS('
@@ -368,12 +368,16 @@ class CartCore extends ObjectModel
{
if (!CartRule::isFeatureActive())
return 0;
-
- return Db::getInstance()->getValue('
- SELECT COUNT(*)
- FROM `'._DB_PREFIX_.'cart_cart_rule`
- WHERE `id_cart_rule` = '.(int)$id_cart_rule.' AND `id_cart` = '.(int)$this->id
- );
+ $cache_id = 'Cart::getDiscountsCustomer_'.(int)$this->id.'-'.(int)$id_cart_rule;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = (int)Db::getInstance()->getValue('
+ SELECT COUNT(*)
+ FROM `'._DB_PREFIX_.'cart_cart_rule`
+ WHERE `id_cart_rule` = '.(int)$id_cart_rule.' AND `id_cart` = '.(int)$this->id);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
public function getLastProduct()
@@ -632,14 +636,19 @@ class CartCore extends ObjectModel
if (!isset($row['pai_id_image']) || $row['pai_id_image'] == 0)
{
- $row2 = Db::getInstance()->getRow('
- SELECT image_shop.`id_image` id_image, il.`legend`
- FROM `'._DB_PREFIX_.'image` i
- JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (i.id_image = image_shop.id_image AND image_shop.cover=1 AND image_shop.id_shop='.(int)$row['id_shop'].')
- LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
- WHERE i.`id_product` = '.(int)$row['id_product'].' AND image_shop.`cover` = 1'
- );
-
+ $cache_id = 'Cart::getProducts_'.'-pai_id_image-'.(int)$row['id_product'].'-'.(int)$this->id_lang.'-'.(int)$row['id_shop'];
+ if (!Cache::isStored($cache_id))
+ {
+ $row2 = Db::getInstance()->getRow('
+ SELECT image_shop.`id_image` id_image, il.`legend`
+ FROM `'._DB_PREFIX_.'image` i
+ JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (i.id_image = image_shop.id_image AND image_shop.cover=1 AND image_shop.id_shop='.(int)$row['id_shop'].')
+ LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
+ WHERE i.`id_product` = '.(int)$row['id_product'].' AND image_shop.`cover` = 122'
+ );
+ Cache::store($cache_id, $row2);
+ }
+ $row2 = Cache::retrieve($cache_id);
if (!$row2)
$row2 = array('id_image' => false, 'legend' => false);
else
@@ -727,7 +736,7 @@ class CartCore extends ObjectModel
*
* @result integer Products quantity
*/
- public function nbProducts()
+ public function nbProducts()
{
if (!$this->id)
return 0;
@@ -1078,9 +1087,9 @@ class CartCore extends ObjectModel
);
$id_customization = Db::getInstance()->Insert_ID();
}
-
+
$query = 'INSERT INTO `'._DB_PREFIX_.'customized_data` (`id_customization`, `type`, `index`, `value`)
- VALUES ('.(int)$id_customization.', '.(int)$type.', '.(int)$index.', \''.pSql($field).'\')';
+ VALUES ('.(int)$id_customization.', '.(int)$type.', '.(int)$index.', \''.pSQL($field).'\')';
if (!Db::getInstance()->execute($query))
return false;
@@ -1094,7 +1103,13 @@ class CartCore extends ObjectModel
*/
public function orderExists()
{
- return (bool)Db::getInstance()->getValue('SELECT count(*) FROM `'._DB_PREFIX_.'orders` WHERE `id_cart` = '.(int)$this->id);
+ $cache_id = 'Cart::orderExists_'.(int)$this->id;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = (bool)Db::getInstance()->getValue('SELECT count(*) FROM `'._DB_PREFIX_.'orders` WHERE `id_cart` = '.(int)$this->id);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -2277,18 +2292,23 @@ class CartCore extends ObjectModel
public function getAddressCollection()
{
$collection = array();
- $result = Db::getInstance()->executeS(
- 'SELECT DISTINCT `id_address_delivery`
- FROM `'._DB_PREFIX_.'cart_product`
- WHERE id_cart = '.(int)$this->id
- );
+ $cache_id = 'Cart::getAddressCollection'.(int)$this->id;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = Db::getInstance()->executeS(
+ 'SELECT DISTINCT `id_address_delivery`
+ FROM `'._DB_PREFIX_.'cart_product`
+ WHERE id_cart = '.(int)$this->id
+ );
+ Cache::store($cache_id, $result);
+ }
+ $result = Cache::retrieve($cache_id);
$result[] = array('id_address_delivery' => (int)$this->id_address_delivery);
foreach ($result as $row)
if ((int)$row['id_address_delivery'] != 0)
$collection[(int)$row['id_address_delivery']] = new Address((int)$row['id_address_delivery']);
-
return $collection;
}
@@ -3038,7 +3058,6 @@ class CartCore extends ObjectModel
*/
public function addTextFieldToProduct($id_product, $index, $type, $text_value)
{
- $text_value = str_replace(array("\n", "\r"), '', nl2br($text_value));
if (!_PS_MAGIC_QUOTES_GPC_){
$text_value = str_replace('\\', '\\\\', $text_value);
$text_value = str_replace('\'', '\\\'', $text_value);
@@ -3466,10 +3485,14 @@ class CartCore extends ObjectModel
)
WHERE `id_cart` = '.(int)$this->id.'
'.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : '');
-
- $result = Db::getInstance()->execute($sql);
- if ($result)
- $emptyCache = true;
+
+ $cache_id = 'Cart::setNoMultishipping'.(int)$this->id.'-'.(int)$this->id_shop;
+ if (!Cache::isStored($cache_id))
+ {
+ if ($result = (bool)Db::getInstance()->execute($sql))
+ $emptyCache = true;
+ Cache::store($cache_id, $result);
+ }
if (Customization::isFeatureActive())
Db::getInstance()->execute('
diff --git a/classes/Category.php b/classes/Category.php
index f787cce56..568e914a0 100644
--- a/classes/Category.php
+++ b/classes/Category.php
@@ -666,9 +666,9 @@ class CategoryCore extends ObjectModel
* @param boolean $active return only active categories
* @return array categories
*/
- public static function getHomeCategories($id_lang, $active = true)
+ public static function getHomeCategories($id_lang, $active = true, $id_shop = false)
{
- return self::getChildren(Configuration::get('PS_HOME_CATEGORY'), $id_lang, $active);
+ return self::getChildren(Configuration::get('PS_HOME_CATEGORY'), $id_lang, $active, $id_shop);
}
public static function getRootCategory($id_lang = null, Shop $shop = null)
@@ -704,16 +704,22 @@ class CategoryCore extends ObjectModel
if (!Validate::isBool($active))
die(Tools::displayError());
- $query = 'SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`, category_shop.`id_shop`
- FROM `'._DB_PREFIX_.'category` c
- LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
- '.Shop::addSqlAssociation('category', 'c').'
- WHERE `id_lang` = '.(int)$id_lang.'
- AND c.`id_parent` = '.(int)$id_parent.'
- '.($active ? 'AND `active` = 1' : '').'
- GROUP BY c.`id_category`
- ORDER BY category_shop.`position` ASC';
- return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
+ $cache_id = 'Category::getChildren_'.(int)$id_parent.'-'.(int)$id_lang.'-'.(bool)$active.'-'.(int)$id_shop;
+ if (!Cache::isStored($cache_id))
+ {
+ $query = 'SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`, category_shop.`id_shop`
+ FROM `'._DB_PREFIX_.'category` c
+ LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
+ '.Shop::addSqlAssociation('category', 'c').'
+ WHERE `id_lang` = '.(int)$id_lang.'
+ AND c.`id_parent` = '.(int)$id_parent.'
+ '.($active ? 'AND `active` = 1' : '').'
+ GROUP BY c.`id_category`
+ ORDER BY category_shop.`position` ASC';
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -1008,14 +1014,20 @@ class CategoryCore extends ObjectModel
public function getGroups()
{
$groups = array();
- $result = Db::getInstance()->executeS('
- SELECT cg.`id_group`
- FROM '._DB_PREFIX_.'category_group cg
- WHERE cg.`id_category` = '.(int)$this->id
- );
- foreach ($result as $group)
- $groups[] = $group['id_group'];
- return $groups;
+ $cache_id = 'Category::getGroups_'.(int)$this->id;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = Db::getInstance()->executeS('
+ SELECT cg.`id_group`
+ FROM '._DB_PREFIX_.'category_group cg
+ WHERE cg.`id_category` = '.(int)$this->id
+ );
+ $groups = array();
+ foreach ($result as $group)
+ $groups[] = $group['id_group'];
+ Cache::store($cache_id, $groups);
+ }
+ return Cache::retrieve($cache_id);
}
public function addGroupsIfNoExist($id_group)
@@ -1036,24 +1048,23 @@ class CategoryCore extends ObjectModel
*/
public function checkAccess($id_customer)
{
- if (!$id_customer)
+ $cache_id = 'Category::checkAccess_'.(int)$this->id.'-'.$id_customer.(!$id_customer ? '-'.(int)Group::getCurrent()->id : '');
+ if (!Cache::isStored($cache_id))
{
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
+ if (!$id_customer)
+ $result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT ctg.`id_group`
FROM '._DB_PREFIX_.'category_group ctg
- WHERE ctg.`id_category` = '.(int)$this->id.' AND ctg.`id_group` = '.(int)Group::getCurrent()->id.'
- ');
- } else {
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
+ WHERE ctg.`id_category` = '.(int)$this->id.' AND ctg.`id_group` = '.(int)Group::getCurrent()->id);
+ else
+ $result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT ctg.`id_group`
FROM '._DB_PREFIX_.'category_group ctg
INNER JOIN '._DB_PREFIX_.'customer_group cg on (cg.`id_group` = ctg.`id_group` AND cg.`id_customer` = '.(int)$id_customer.')
- WHERE ctg.`id_category` = '.(int)$this->id
- );
+ WHERE ctg.`id_category` = '.(int)$this->id);
+ Cache::store($cache_id, $result);
}
- if ($result && isset($result['id_group']) && $result['id_group'])
- return true;
- return false;
+ return Cache::retrieve($cache_id);
}
/**
@@ -1199,12 +1210,16 @@ class CategoryCore extends ObjectModel
*/
public static function getInterval($id)
{
- $sql = 'SELECT nleft, nright, level_depth
- FROM '._DB_PREFIX_.'category
- WHERE id_category = '.(int)$id;
- if (!$result = Db::getInstance()->getRow($sql))
- return false;
- return $result;
+ $cache_id = 'Category::getInterval_'.(int)$id;
+ if (!Cache::isStored($cache_id))
+ {
+ $sql = 'SELECT nleft, nright, level_depth
+ FROM '._DB_PREFIX_.'category
+ WHERE id_category = '.(int)$id;
+ $result = Db::getInstance()->getRow($sql);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -1386,11 +1401,17 @@ class CategoryCore extends ObjectModel
public static function getCategoriesWithoutParent()
{
- return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
- SELECT DISTINCT c.*
- FROM `'._DB_PREFIX_.'category` c
- LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)Context::getContext()->language->id.')
- WHERE `level_depth` = 1');
+ $cache_id = 'Category::getCategoriesWithoutParent_'.(int)Context::getContext()->language->id;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
+ SELECT DISTINCT c.*
+ FROM `'._DB_PREFIX_.'category` c
+ LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)Context::getContext()->language->id.')
+ WHERE `level_depth` = 1');
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
public function isRootCategoryForAShop()
@@ -1409,12 +1430,17 @@ class CategoryCore extends ObjectModel
public static function getTopCategory($id_lang = null)
{
if (is_null($id_lang))
- $id_lang = Context::getContext()->language->id;
- $id_category = Db::getInstance()->getValue('
- SELECT `id_category`
- FROM `'._DB_PREFIX_.'category`
- WHERE `id_parent` = 0');
- return new Category($id_category, $id_lang);
+ $id_lang = (int)Context::getContext()->language->id;
+ $cache_id = 'Category::getTopCategory_'.(int)$id_lang;
+ if (!Cache::isStored($cache_id))
+ {
+ $id_category = (int)Db::getInstance()->getValue('
+ SELECT `id_category`
+ FROM `'._DB_PREFIX_.'category`
+ WHERE `id_parent` = 0');
+ Cache::store($cache_id, new Category($id_category, $id_lang));
+ }
+ return Cache::retrieve($cache_id);
}
public function addPosition($position, $id_shop = null)
diff --git a/classes/Currency.php b/classes/Currency.php
index 3280ec189..d92660542 100644
--- a/classes/Currency.php
+++ b/classes/Currency.php
@@ -296,10 +296,16 @@ class CurrencyCore extends ObjectModel
*/
public static function getIdByIsoCode($iso_code, $id_shop = 0)
{
- $query = Currency::getIdByQuery($id_shop);
- $query->where('iso_code = \''.pSQL($iso_code).'\'');
-
- return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query->build());
+ $cache_id = 'Currency::getIdByIsoCode_'.pSQL($iso_code).'-'.(int)$id_shop;
+ if (!Cache::isStored($cache_id))
+ {
+ $query = Currency::getIdByQuery($id_shop);
+ $query->where('iso_code = \''.pSQL($iso_code).'\'');
+
+ $result = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query->build());
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/classes/Customer.php b/classes/Customer.php
index 431d217e6..8191d3ee6 100644
--- a/classes/Customer.php
+++ b/classes/Customer.php
@@ -362,15 +362,18 @@ class CustomerCore extends ObjectModel
{
if (!Validate::isUnsignedId($id_customer))
return true;
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
- SELECT `id_customer`
- FROM `'._DB_PREFIX_.'customer`
- WHERE `id_customer` = \''.(int)$id_customer.'\'
- AND active = 1
- AND `deleted` = 0');
- if (isset($result['id_customer']))
- return false;
- return true;
+ $cache_id = 'Customer::isBanned_'.(int)$id_customer;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = (bool)!Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
+ SELECT `id_customer`
+ FROM `'._DB_PREFIX_.'customer`
+ WHERE `id_customer` = \''.(int)$id_customer.'\'
+ AND active = 1
+ AND `deleted` = 0');
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -413,7 +416,7 @@ class CustomerCore extends ObjectModel
public static function customerHasAddress($id_customer, $id_address)
{
$key = (int)$id_customer.'-'.(int)$id_address;
- if (!array_key_exists($id_address, self::$_customerHasAddress))
+ if (!array_key_exists($key, self::$_customerHasAddress))
{
self::$_customerHasAddress[$key] = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_address`
@@ -439,15 +442,22 @@ class CustomerCore extends ObjectModel
*/
public function getAddresses($id_lang)
{
- $sql = 'SELECT DISTINCT a.*, cl.`name` AS country, s.name AS state, s.iso_code AS state_iso
- FROM `'._DB_PREFIX_.'address` a
- LEFT JOIN `'._DB_PREFIX_.'country` c ON (a.`id_country` = c.`id_country`)
- LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
- LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = a.`id_state`)
- '.(Context::getContext()->shop->getGroup()->share_order ? '' : Shop::addSqlAssociation('country', 'c')).'
- WHERE `id_lang` = '.(int)$id_lang.' AND `id_customer` = '.(int)$this->id.' AND a.`deleted` = 0';
+ $share_order = (bool)Context::getContext()->shop->getGroup()->share_order;
+ $cache_id = 'Customer::getAddresses'.(int)$this->id.'-'.(int)$id_lang.'-'.$share_order;
+ if (!Cache::isStored($cache_id))
+ {
+ $sql = 'SELECT DISTINCT a.*, cl.`name` AS country, s.name AS state, s.iso_code AS state_iso
+ FROM `'._DB_PREFIX_.'address` a
+ LEFT JOIN `'._DB_PREFIX_.'country` c ON (a.`id_country` = c.`id_country`)
+ LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
+ LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = a.`id_state`)
+ '.($share_order ? '' : Shop::addSqlAssociation('country', 'c')).'
+ WHERE `id_lang` = '.(int)$id_lang.' AND `id_customer` = '.(int)$this->id.' AND a.`deleted` = 0';
- return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -476,12 +486,17 @@ class CustomerCore extends ObjectModel
{
if (!Validate::isUnsignedId($id_customer) || !Validate::isMd5($passwd))
die (Tools::displayError());
-
- $sql = 'SELECT `id_customer`
- FROM `'._DB_PREFIX_.'customer`
- WHERE `id_customer` = '.$id_customer.'
+ $cache_id = 'Customer::checkPassword'.(int)$id_customer.'-'.$passwd;
+ if (!Cache::isStored($cache_id))
+ {
+ $sql = 'SELECT `id_customer`
+ FROM `'._DB_PREFIX_.'customer`
+ WHERE `id_customer` = '.$id_customer.'
AND `passwd` = \''.$passwd.'\'';
- return (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
+ $result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -574,12 +589,16 @@ class CustomerCore extends ObjectModel
public static function customerIdExistsStatic($id_customer)
{
- $row = Db::getInstance()->getRow('
- SELECT `id_customer`
- FROM '._DB_PREFIX_.'customer c
- WHERE c.`id_customer` = '.(int)$id_customer);
-
- return isset($row['id_customer']);
+ $cache_id = 'Customer::customerIdExistsStatic'.(int)$id_customer;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = (int)Db::getInstance()->getValue('
+ SELECT `id_customer`
+ FROM '._DB_PREFIX_.'customer c
+ WHERE c.`id_customer` = '.(int)$id_customer);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/classes/Group.php b/classes/Group.php
index 08893046f..2e43e5f0d 100644
--- a/classes/Group.php
+++ b/classes/Group.php
@@ -305,12 +305,21 @@ class GroupCore extends ObjectModel
public static function getCurrent()
{
static $groups = array();
+
$customer = Context::getContext()->customer;
if (Validate::isLoadedObject($customer))
+ {
$id_group = (int)$customer->id_default_group;
+ $group = new Group((int)$id_group);
+ if (!$group->isAssociatedToShop(Context::getContext()->shop->id))
+ $group = new Group((int)Configuration::get('PS_CUSTOMER_GROUP'));
+ }
else
$id_group = (int)Configuration::get('PS_UNIDENTIFIED_GROUP');
-
+
+ if (!isset($groups[$id_group]) && isset($group))
+ $groups[$id_group] = $group;
+
if (!isset($groups[$id_group]))
$groups[$id_group] = new Group($id_group);
diff --git a/classes/Hook.php b/classes/Hook.php
index 656934e16..7ed27a3de 100644
--- a/classes/Hook.php
+++ b/classes/Hook.php
@@ -326,7 +326,10 @@ class HookCore extends ObjectModel
if ($frontend)
{
$sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`');
- $sql->where('mg.`id_group` IN ('.implode(', ', $groups).')');
+ if (Validate::isLoadedObject($context->shop))
+ $sql->where('mg.id_shop = '.((int)$context->shop->id).' AND mg.`id_group` IN ('.implode(', ', $groups).')');
+ else
+ $sql->where('mg.`id_group` IN ('.implode(', ', $groups).')');
$sql->groupBy('hm.id_hook, hm.id_module');
}
diff --git a/classes/Language.php b/classes/Language.php
index ce3762ab2..ffa4b12e9 100644
--- a/classes/Language.php
+++ b/classes/Language.php
@@ -619,6 +619,35 @@ class LanguageCore extends ObjectModel
return Db::getInstance()->getValue('SELECT `language_code` FROM `'._DB_PREFIX_.'lang` WHERE `iso_code` = \''.pSQL(strtolower($iso_code)).'\'');
}
+ public static function getLanguageByIETFCode($code)
+ {
+ if (!Validate::isLanguageCode($code))
+ die(sprintf(Tools::displayError('Fatal error: IETF code %s is not correct'), $code));
+
+ // $code is in the form of 'xx-YY' where xx is the language code
+ // and 'YY' a country code identifying a variant of the language.
+ $lang_country = explode('-', $code);
+ // Get the language component of the code
+ $lang = $lang_country[0];
+
+ // Find the id_lang of the language.
+ // We look for anything with the correct language code
+ // and sort on equality with the exact IETF code wanted.
+ // That way using only one query we get either the exact wanted language
+ // or a close match.
+ $id_lang = Db::getInstance()->getValue(
+ 'SELECT `id_lang` FROM '
+ .'`'._DB_PREFIX_.'lang` WHERE LEFT(`language_code`,2) = \''.pSQL($lang).'\' '
+ .'ORDER BY language_code = \''.pSQL($code).'\' DESC'
+ );
+
+ // Instantiate the Language object if we found it.
+ if ($id_lang)
+ return new Language($id_lang);
+ else
+ return false;
+ }
+
/**
* Return array (id_lang, iso_code)
*
diff --git a/classes/Link.php b/classes/Link.php
index cb207e6db..f908e7225 100644
--- a/classes/Link.php
+++ b/classes/Link.php
@@ -423,6 +423,15 @@ class LinkCore
*/
public function getPageLink($controller, $ssl = null, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null)
{
+
+ //If $controller contains '&' char, it means that $controller contains request data and must be parsed first
+ $p = strpos($controller, '&');
+ if ($p !== false) {
+ $request = substr($controller, $p + 1);
+ $request_url_encode = false;
+ $controller = substr($controller, 0, $p);
+ }
+
$controller = Tools::strReplaceFirst('.php', '', $controller);
if (!$id_lang)
$id_lang = (int)Context::getContext()->language->id;
diff --git a/classes/LocalizationPack.php b/classes/LocalizationPack.php
index 5a738b1a4..6cf02bc8c 100644
--- a/classes/LocalizationPack.php
+++ b/classes/LocalizationPack.php
@@ -63,6 +63,7 @@ class LocalizationPackCore
if ($install_mode && $res && isset($this->iso_currency))
{
+ Cache::clean('Currency::getIdByIsoCode_*');
$res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int)Currency::getIdByIsoCode($this->iso_currency));
Currency::refreshCurrencies();
}
diff --git a/classes/Meta.php b/classes/Meta.php
index 4e911fe72..1612812b1 100644
--- a/classes/Meta.php
+++ b/classes/Meta.php
@@ -277,24 +277,31 @@ class MetaCore extends ObjectModel
FROM `'._DB_PREFIX_.'category_lang` cl
WHERE cl.`id_lang` = '.(int)$id_lang.'
AND cl.`id_category` = '.(int)$id_category.Shop::addSqlRestrictionOnLang('cl');
- if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
+
+ $cache_id = 'Meta::getCategoryMetas'.(int)$id_category.'-'.(int)$id_lang;
+ if (!Cache::isStored($cache_id))
{
- if (empty($row['meta_description']))
- $row['meta_description'] = strip_tags($row['description']);
-
- // Paginate title
- if (!empty($row['meta_title']))
- $row['meta_title'] = $title.$row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
+ if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
+ {
+ if (empty($row['meta_description']))
+ $row['meta_description'] = strip_tags($row['description']);
+
+ // Paginate title
+ if (!empty($row['meta_title']))
+ $row['meta_title'] = $title.$row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
+ else
+ $row['meta_title'] = $row['name'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
+
+ if (!empty($title))
+ $row['meta_title'] = $title.(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
+
+ $result = Meta::completeMetaTags($row, $row['name']);
+ }
else
- $row['meta_title'] = $row['name'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
-
- if (!empty($title))
- $row['meta_title'] = $title.(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
-
- return Meta::completeMetaTags($row, $row['name']);
+ $result = Meta::getHomeMetas($id_lang, $page_name);
+ Cache::store($cache_id, $result);
}
-
- return Meta::getHomeMetas($id_lang, $page_name);
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php
index 0c70cbf3c..783cd6abf 100644
--- a/classes/ObjectModel.php
+++ b/classes/ObjectModel.php
@@ -191,7 +191,7 @@ abstract class ObjectModelCore
if ($id)
{
// Load object from database if object id is present
- $cache_id = 'objectmodel_'.$this->def['classname'].'_'.(int)$id.'_'.(int)$id_shop.'_'.(int)$id_lang;
+ $cache_id = 'objectmodel_'.$this->def['classname'].'_'.(int)$id.'_'.(int)$this->id_shop.'_'.(int)$id_lang;
if (!Cache::isStored($cache_id))
{
$sql = new DbQuery();
@@ -1234,11 +1234,16 @@ abstract class ObjectModelCore
if ($id_shop === null)
$id_shop = Context::getContext()->shop->id;
- $sql = 'SELECT id_shop
- FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_shop`
- WHERE `'.$this->def['primary'].'` = '.(int)$this->id.'
- AND id_shop = '.(int)$id_shop;
- return (bool)Db::getInstance()->getValue($sql);
+ $cache_id = 'objectmodel_shop_'.$this->def['classname'].'_'.(int)$this->id.'-'.(int)$id_shop;
+ if (!Cache::isStored($cache_id))
+ {
+ $sql = 'SELECT id_shop
+ FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_shop`
+ WHERE `'.$this->def['primary'].'` = '.(int)$this->id.'
+ AND id_shop = '.(int)$id_shop;
+ Cache::store($cache_id, (bool)Db::getInstance()->getValue($sql));
+ }
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/classes/Product.php b/classes/Product.php
index 0d54b9752..6bfdc8c53 100644
--- a/classes/Product.php
+++ b/classes/Product.php
@@ -229,7 +229,13 @@ class ProductCore extends ObjectModel
protected static $_prices = array();
protected static $_pricesLevel2 = array();
protected static $_incat = array();
+
+ /**
+ * @since 1.5.6.1
+ * @var array $_cart_quantity is deprecated since 1.5.6.1
+ */
protected static $_cart_quantity = array();
+
protected static $_tax_rules_group = array();
protected static $_cacheFeatures = array();
protected static $_frontFeaturesCache = array();
@@ -2434,13 +2440,18 @@ class ProductCore extends ObjectModel
{
if (!$context)
$context = Context::getContext();
-
- $sql = 'SELECT image_shop.`id_image`
- FROM `'._DB_PREFIX_.'image` i
- '.Shop::addSqlAssociation('image', 'i').'
- WHERE i.`id_product` = '.(int)$id_product.'
- AND image_shop.`cover` = 1';
- return Db::getInstance()->getRow($sql);
+ $cache_id = 'Product::getOrderStates_'.(int)$id_product.'-'.(int)$context->shop->id;
+ if (!Cache::isStored($cache_id))
+ {
+ $sql = 'SELECT image_shop.`id_image`
+ FROM `'._DB_PREFIX_.'image` i
+ '.Shop::addSqlAssociation('image', 'i').'
+ WHERE i.`id_product` = '.(int)$id_product.'
+ AND image_shop.`cover` = 1';
+ $result = Db::getInstance()->getRow($sql);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -2502,15 +2513,17 @@ class ProductCore extends ObjectModel
$cart_quantity = 0;
if ((int)$id_cart)
{
- $condition = '';
- $cache_name = (int)$id_cart.'_'.(int)$id_product;
- if (!isset(self::$_cart_quantity[$cache_name]) || self::$_cart_quantity[$cache_name] != (int)$quantity)
- self::$_cart_quantity[$cache_name] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
- SELECT SUM(`quantity`)
+ $cache_id = 'Product::getPriceStatic_'.(int)$id_product.'-'.(int)$id_cart;
+ if (!Cache::isStored($cache_id))
+ {
+ $sql = 'SELECT SUM(`quantity`)
FROM `'._DB_PREFIX_.'cart_product`
WHERE `id_product` = '.(int)$id_product.'
- AND `id_cart` = '.(int)$id_cart);
- $cart_quantity = self::$_cart_quantity[$cache_name];
+ AND `id_cart` = '.(int)$id_cart;
+ $cart_quantity = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
+ Cache::store($cache_id, $cart_quantity);
+ }
+ $cart_quantity = Cache::retrieve($cache_id);
}
$id_currency = (int)Validate::isLoadedObject($context->currency) ? $context->currency->id : Configuration::get('PS_CURRENCY_DEFAULT');
@@ -4300,19 +4313,25 @@ class ProductCore extends ObjectModel
public function checkAccess($id_customer)
{
- if (!$id_customer)
- return (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
- SELECT ctg.`id_group`
- FROM `'._DB_PREFIX_.'category_product` cp
- INNER JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
- WHERE cp.`id_product` = '.(int)$this->id.' AND ctg.`id_group` ='.(int)Group::getCurrent()->id);
- else
- return (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
- SELECT cg.`id_group`
- FROM `'._DB_PREFIX_.'category_product` cp
- INNER JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
- INNER JOIN `'._DB_PREFIX_.'customer_group` cg ON (cg.`id_group` = ctg.`id_group`)
- WHERE cp.`id_product` = '.(int)$this->id.' AND cg.`id_customer` = '.(int)$id_customer);
+ $cache_id = 'Product::checkAccess_'.(int)$this->id.'-'.(int)$id_customer.(!$id_customer ? '-'.(int)Group::getCurrent()->id : '');
+ if (!Cache::isStored($cache_id))
+ {
+ if (!$id_customer)
+ $result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
+ SELECT ctg.`id_group`
+ FROM `'._DB_PREFIX_.'category_product` cp
+ INNER JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
+ WHERE cp.`id_product` = '.(int)$this->id.' AND ctg.`id_group` = '.(int)Group::getCurrent()->id);
+ else
+ $result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
+ SELECT cg.`id_group`
+ FROM `'._DB_PREFIX_.'category_product` cp
+ INNER JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
+ INNER JOIN `'._DB_PREFIX_.'customer_group` cg ON (cg.`id_group` = ctg.`id_group`)
+ WHERE cp.`id_product` = '.(int)$this->id.' AND cg.`id_customer` = '.(int)$id_customer);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
@@ -4872,8 +4891,12 @@ class ProductCore extends ObjectModel
*/
public static function getAttributesParams($id_product, $id_product_attribute)
{
+ $id_lang = (int)Context::getContext()->language->id;
+ $id_shop = (int)Context::getContext()->shop->id;
+ $cache_id = 'Product::getAttributesParams_'.(int)$id_product.'-'.(int)$id_product_attribute.'-'.(int)$id_lang.'-'.(int)$id_shop;
+
// if blocklayered module is installed we check if user has set custom attribute name
- if (Module::isInstalled('blocklayered'))
+ if (Module::isInstalled('blocklayered') && Module::isEnabled('blocklayered'))
{
$nb_custom_values = Db::getInstance()->executeS('
SELECT DISTINCT la.`id_attribute`, la.`url_name` as `name`
@@ -4884,7 +4907,7 @@ class ProductCore extends ObjectModel
ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
'.Shop::addSqlAssociation('product_attribute', 'pa').'
LEFT JOIN `'._DB_PREFIX_.'layered_indexable_attribute_lang_value` la
- ON (la.`id_attribute` = a.`id_attribute` AND la.`id_lang` = '.(int)Context::getContext()->language->id.')
+ ON (la.`id_attribute` = a.`id_attribute` AND la.`id_lang` = '.(int)$id_lang.')
WHERE la.`url_name` IS NOT NULL AND la.`url_name` != \'\'
AND pa.`id_product` = '.(int)$id_product.'
AND pac.`id_product_attribute` = '.(int)$id_product_attribute);
@@ -4902,7 +4925,7 @@ class ProductCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'attribute` a
ON (a.`id_attribute_group` = g.`id_attribute_group`)
WHERE a.`id_attribute` = '.(int)$attribute['id_attribute'].'
- AND g.`id_lang` = '.(int)Context::getContext()->language->id.'
+ AND g.`id_lang` = '.(int)$id_lang.'
AND g.`url_name` IS NOT NULL AND g.`url_name` != \'\'');
if (empty($group))
{
@@ -4912,7 +4935,7 @@ class ProductCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'attribute` a
ON (a.`id_attribute_group` = g.`id_attribute_group`)
WHERE a.`id_attribute` = '.(int)$attribute['id_attribute'].'
- AND g.`id_lang` = '.(int)Context::getContext()->language->id.'
+ AND g.`id_lang` = '.(int)$id_lang.'
AND g.`name` IS NOT NULL');
}
$result[] = array_merge($attribute, $group[0]);
@@ -4921,9 +4944,9 @@ class ProductCore extends ObjectModel
SELECT DISTINCT a.`id_attribute_group`, al.`name`, agl.`name` as `group`
FROM `'._DB_PREFIX_.'attribute` a
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
- ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
+ ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
- ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
+ ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
ON (a.`id_attribute` = pac.`id_attribute`)
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
@@ -4932,45 +4955,30 @@ class ProductCore extends ObjectModel
WHERE pa.`id_product` = '.(int)$id_product.'
AND pac.id_product_attribute = '.(int)$id_product_attribute.'
AND a.`id_attribute` NOT IN('.implode(', ', $tab_id_attribute).')');
- $result = array_merge($values_not_custom, $result);
- }
- else
- {
- $result = Db::getInstance()->executeS('
- SELECT al.`name`, agl.`name` as `group`
- FROM `'._DB_PREFIX_.'attribute` a
- LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
- ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
- LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
- ON (pac.`id_attribute` = a.`id_attribute`)
- LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
- ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
- '.Shop::addSqlAssociation('product_attribute', 'pa').'
- LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
- ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
- WHERE pa.`id_product` = '.(int)$id_product.'
- AND pac.`id_product_attribute` = '.(int)$id_product_attribute.'
- AND agl.`id_lang` = '.(int)Context::getContext()->language->id);
+ return array_merge($values_not_custom, $result);
}
}
- else
+
+ if (!Cache::isStored($cache_id))
{
$result = Db::getInstance()->executeS('
SELECT al.`name`, agl.`name` as `group`
FROM `'._DB_PREFIX_.'attribute` a
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
- ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
+ ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
ON (pac.`id_attribute` = a.`id_attribute`)
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
'.Shop::addSqlAssociation('product_attribute', 'pa').'
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
- ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
+ ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$id_lang.')
WHERE pa.`id_product` = '.(int)$id_product.'
AND pac.`id_product_attribute` = '.(int)$id_product_attribute.'
- AND agl.`id_lang` = '.(int)Context::getContext()->language->id);
+ AND agl.`id_lang` = '.(int)$id_lang);
+ Cache::store($cache_id, $result);
}
+ $result = Cache::retrieve($cache_id);
return $result;
}
diff --git a/classes/ProductSale.php b/classes/ProductSale.php
index 7acfa7d9b..eef056ade 100644
--- a/classes/ProductSale.php
+++ b/classes/ProductSale.php
@@ -89,7 +89,6 @@ class ProductSaleCore
$ids = count($ids) > 0 ? implode(',', $ids) : 'NULL';
//Main query
- if ($order_by == 'date_add')
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
diff --git a/classes/State.php b/classes/State.php
index e818c07a5..205868a81 100644
--- a/classes/State.php
+++ b/classes/State.php
@@ -80,13 +80,19 @@ class StateCore extends ObjectModel
*/
public static function getNameById($id_state)
{
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
- SELECT `name`
- FROM `'._DB_PREFIX_.'state`
- WHERE `id_state` = '.(int)$id_state
- );
-
- return $result['name'];
+ if (!$id_state)
+ return false;
+ $cache_id = 'State::getNameById_'.(int)$id_state;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
+ SELECT `name`
+ FROM `'._DB_PREFIX_.'state`
+ WHERE `id_state` = '.(int)$id_state
+ );
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -97,13 +103,19 @@ class StateCore extends ObjectModel
*/
public static function getIdByName($state)
{
- $result = Db::getInstance()->getValue('
- SELECT `id_state`
- FROM `'._DB_PREFIX_.'state`
- WHERE `name` LIKE \''.pSQL($state).'\'
- ');
-
- return (int)$result;
+ if (empty($state))
+ return false;
+ $cache_id = 'State::getNameById_'.pSQL($state);
+ if (!Cache::isStored($cache_id))
+ {
+ $result = (int)Db::getInstance()->getValue('
+ SELECT `id_state`
+ FROM `'._DB_PREFIX_.'state`
+ WHERE `name` LIKE \''.pSQL($state).'\'
+ ');
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/classes/Tab.php b/classes/Tab.php
index 94cb98de4..e6e14686b 100644
--- a/classes/Tab.php
+++ b/classes/Tab.php
@@ -190,14 +190,20 @@ class TabCore extends ObjectModel
*/
public static function getTab($id_lang, $id_tab)
{
- /* Tabs selection */
- return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
- SELECT *
- FROM `'._DB_PREFIX_.'tab` t
- LEFT JOIN `'._DB_PREFIX_.'tab_lang` tl
- ON (t.`id_tab` = tl.`id_tab` AND tl.`id_lang` = '.(int)$id_lang.')
- WHERE t.`id_tab` = '.(int)$id_tab
- );
+ $cache_id = 'Tab::getTab_'.(int)$id_lang.'-'.(int)$id_tab;
+ if (!Cache::isStored($cache_id))
+ {
+ /* Tabs selection */
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
+ SELECT *
+ FROM `'._DB_PREFIX_.'tab` t
+ LEFT JOIN `'._DB_PREFIX_.'tab_lang` tl
+ ON (t.`id_tab` = tl.`id_tab` AND tl.`id_lang` = '.(int)$id_lang.')
+ WHERE t.`id_tab` = '.(int)$id_tab
+ );
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/classes/Tools.php b/classes/Tools.php
index dc6a74cd4..801d9bf4b 100644
--- a/classes/Tools.php
+++ b/classes/Tools.php
@@ -346,17 +346,12 @@ class ToolsCore
/* Automatically detect language if not already defined, detect_language is set in Cookie::update */
if ((!$cookie->id_lang || isset($cookie->detect_language)) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
- $array = explode(',', Tools::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
- if (Tools::strlen($array[0]) > 2)
+ $array = explode(',', Tools::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
+ $string = $array[0];
+
+ if (Validate::isLanguageCode($string))
{
- $tab = explode('-', $array[0]);
- $string = $tab[0];
- }
- else
- $string = $array[0];
- if (Validate::isLanguageIsoCode($string))
- {
- $lang = new Language(Language::getIdByIso($string));
+ $lang = Language::getLanguageByIETFCode($string);
if (Validate::isLoadedObject($lang) && $lang->active && $lang->isAssociatedToShop())
{
Context::getContext()->language = $lang;
@@ -364,7 +359,7 @@ class ToolsCore
}
}
}
-
+
if (isset($cookie->detect_language))
unset($cookie->detect_language);
@@ -374,7 +369,7 @@ class ToolsCore
$iso = Language::getIsoById((int)$cookie->id_lang);
@include_once(_PS_THEME_DIR_.'lang/'.$iso.'.php');
-
+
return $iso;
}
@@ -689,9 +684,10 @@ class ToolsCore
public static function safePostVars()
{
- if (!is_array($_POST))
- return array();
- $_POST = array_map(array('Tools', 'htmlentitiesUTF8'), $_POST);
+ if (!isset($_POST) || !is_array($_POST))
+ $_POST = array();
+ else
+ $_POST = array_map(array('Tools', 'htmlentitiesUTF8'), $_POST);
}
/**
diff --git a/classes/Zone.php b/classes/Zone.php
index 699a90e52..1d39ad7b2 100644
--- a/classes/Zone.php
+++ b/classes/Zone.php
@@ -54,12 +54,18 @@ class ZoneCore extends ObjectModel
*/
public static function getZones($active = false)
{
- return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
- SELECT *
- FROM `'._DB_PREFIX_.'zone`
- '.($active ? 'WHERE active = 1' : '').'
- ORDER BY `name` ASC
- ');
+ $cache_id = 'Zone::getZones_'.(bool)$active;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
+ SELECT *
+ FROM `'._DB_PREFIX_.'zone`
+ '.($active ? 'WHERE active = 1' : '').'
+ ORDER BY `name` ASC
+ ');
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/classes/db/Db.php b/classes/db/Db.php
index be9f1530a..2583396b1 100755
--- a/classes/db/Db.php
+++ b/classes/db/Db.php
@@ -523,13 +523,13 @@ abstract class DbCore
$this->last_cached = true;
return $result;
}
-
$this->result = $this->query($sql);
if (!$this->result)
return false;
-
$this->last_cached = false;
$result = $this->nextRow($this->result);
+ if (is_null($result))
+ $result = false;
if ($use_cache && $this->is_cache_enabled)
Cache::getInstance()->setQuery($sql, $result);
return $result;
diff --git a/classes/module/Module.php b/classes/module/Module.php
index b516a54b4..f6e3c6473 100644
--- a/classes/module/Module.php
+++ b/classes/module/Module.php
@@ -1864,7 +1864,13 @@ abstract class ModuleCore
*/
public static function getModuleIdByName($name)
{
- return Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = "'.pSQL($name).'"');
+ $cache_id = 'Module::getModuleIdByName_'.pSQL($name);
+ if (!Cache::isStored($cache_id))
+ {
+ $result = (int)Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = "'.pSQL($name).'"');
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/classes/order/Order.php b/classes/order/Order.php
index e57bf651d..bf72b83fe 100644
--- a/classes/order/Order.php
+++ b/classes/order/Order.php
@@ -721,11 +721,17 @@ class OrderCore extends ObjectModel
public static function getDiscountsCustomer($id_customer, $id_cart_rule)
{
- return Db::getInstance()->getValue('
- SELECT COUNT(*) FROM `'._DB_PREFIX_.'orders` o
- LEFT JOIN '._DB_PREFIX_.'order_cart_rule ocr ON (ocr.id_order = o.id_order)
- WHERE o.id_customer = '.(int)$id_customer.'
- AND ocr.id_cart_rule = '.(int)$id_cart_rule);
+ $cache_id = 'Order::getDiscountsCustomer_'.(int)$id_customer.'-'.(int)$id_cart_rule;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = (int)Db::getInstance()->getValue('
+ SELECT COUNT(*) FROM `'._DB_PREFIX_.'orders` o
+ LEFT JOIN '._DB_PREFIX_.'order_cart_rule ocr ON (ocr.id_order = o.id_order)
+ WHERE o.id_customer = '.(int)$id_customer.'
+ AND ocr.id_cart_rule = '.(int)$id_cart_rule);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/classes/order/OrderState.php b/classes/order/OrderState.php
index 7cc1d5375..19dddb875 100644
--- a/classes/order/OrderState.php
+++ b/classes/order/OrderState.php
@@ -112,12 +112,18 @@ class OrderStateCore extends ObjectModel
*/
public static function getOrderStates($id_lang)
{
- return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
- SELECT *
- FROM `'._DB_PREFIX_.'order_state` os
- LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$id_lang.')
- WHERE deleted = 0
- ORDER BY `name` ASC');
+ $cache_id = 'OrderState::getOrderStates_'.(int)$id_lang;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
+ SELECT *
+ FROM `'._DB_PREFIX_.'order_state` os
+ LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$id_lang.')
+ WHERE deleted = 0
+ ORDER BY `name` ASC');
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php
index 98ae61c53..ee7dddcf7 100644
--- a/classes/shop/Shop.php
+++ b/classes/shop/Shop.php
@@ -187,14 +187,19 @@ class ShopCore extends ObjectModel
public function setUrl()
{
- $row = Db::getInstance()->getRow('
- SELECT su.physical_uri, su.virtual_uri, su.domain, su.domain_ssl, t.id_theme, t.name, t.directory
- FROM '._DB_PREFIX_.'shop s
- LEFT JOIN '._DB_PREFIX_.'shop_url su ON (s.id_shop = su.id_shop)
- LEFT JOIN '._DB_PREFIX_.'theme t ON (t.id_theme = s.id_theme)
- WHERE s.id_shop = '.(int)$this->id.'
- AND s.active = 1 AND s.deleted = 0 AND su.main = 1');
-
+ $cache_id = 'Shop::setUrl_'.(int)$this->id;
+ if (!Cache::isStored($cache_id))
+ {
+ $row = Db::getInstance()->getRow('
+ SELECT su.physical_uri, su.virtual_uri, su.domain, su.domain_ssl, t.id_theme, t.name, t.directory
+ FROM '._DB_PREFIX_.'shop s
+ LEFT JOIN '._DB_PREFIX_.'shop_url su ON (s.id_shop = su.id_shop)
+ LEFT JOIN '._DB_PREFIX_.'theme t ON (t.id_theme = s.id_theme)
+ WHERE s.id_shop = '.(int)$this->id.'
+ AND s.active = 1 AND s.deleted = 0 AND su.main = 1');
+ Cache::store($cache_id, $row);
+ }
+ $row = Cache::retrieve($cache_id);
if (!$row)
return false;
diff --git a/classes/stock/StockAvailable.php b/classes/stock/StockAvailable.php
index dbe95389f..ef2bd6c29 100644
--- a/classes/stock/StockAvailable.php
+++ b/classes/stock/StockAvailable.php
@@ -53,6 +53,8 @@ class StockAvailableCore extends ObjectModel
/** @var bool determine if a product is out of stock - it was previously in Product class */
public $out_of_stock = false;
+ protected static $cache_quantity_available;
+
/**
* @see ObjectModel::$definition
*/
@@ -343,18 +345,23 @@ class StockAvailableCore extends ObjectModel
if ($id_product_attribute === null)
$id_product_attribute = 0;
- $query = new DbQuery();
- $query->select('SUM(quantity)');
- $query->from('stock_available');
+ $key = (int)$id_product.'-'.(int)$id_product_attribute.'-'.(int)$id_shop;
+ if (!isset(self::$cache_quantity_available[$key]))
+ {
+ $query = new DbQuery();
+ $query->select('SUM(quantity)');
+ $query->from('stock_available');
+
+ // if null, it's a product without attributes
+ if ($id_product !== null)
+ $query->where('id_product = '.(int)$id_product);
+
+ $query->where('id_product_attribute = '.(int)$id_product_attribute);
+ $query = StockAvailable::addSqlShopRestriction($query, $id_shop);
- // if null, it's a product without attributes
- if ($id_product !== null)
- $query->where('id_product = '.(int)$id_product);
-
- $query->where('id_product_attribute = '.(int)$id_product_attribute);
- $query = StockAvailable::addSqlShopRestriction($query, $id_shop);
-
- return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
+ self::$cache_quantity_available[$key] = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
+ }
+ return self::$cache_quantity_available[$key];
}
/**
diff --git a/classes/tax/TaxRule.php b/classes/tax/TaxRule.php
index e59a2ddb9..b41d61fa1 100644
--- a/classes/tax/TaxRule.php
+++ b/classes/tax/TaxRule.php
@@ -124,9 +124,13 @@ class TaxRuleCore extends ObjectModel
*/
public static function isTaxInUse($id_tax)
{
- return Db::getInstance()->getValue('
- SELECT COUNT(*) FROM `'._DB_PREFIX_.'tax_rule` WHERE `id_tax` = '.(int)$id_tax
- );
+ $cache_id = 'TaxRule::isTaxInUse_'.(int)$id_tax;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = (int)Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'tax_rule` WHERE `id_tax` = '.(int)$id_tax);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
diff --git a/classes/tax/TaxRulesTaxManager.php b/classes/tax/TaxRulesTaxManager.php
index 99cbea94d..ae6beeb67 100644
--- a/classes/tax/TaxRulesTaxManager.php
+++ b/classes/tax/TaxRulesTaxManager.php
@@ -33,9 +33,6 @@ class TaxRulesTaxManagerCore implements TaxManagerInterface
public $type;
public $tax_calculator;
- protected static $cache_tax_calculator;
-
-
/**
*
* @param Address $address
@@ -80,7 +77,8 @@ class TaxRulesTaxManagerCore implements TaxManagerInterface
if (!empty($this->address->postcode))
$postcode = $this->address->postcode;
- if (!isset(self::$cache_tax_calculator[(int)$this->address->id_country.'-'.$postcode.'-'.$this->type]))
+ $cache_id = (int)$this->address->id_country.'-'.(int)$this->address->id_state.'-'.$postcode.'-'.(int)$this->type;
+ if (!Cache::isStored($cache_id))
{
$rows = Db::getInstance()->executeS('
SELECT *
@@ -110,11 +108,8 @@ class TaxRulesTaxManagerCore implements TaxManagerInterface
if ($row['behavior'] == 0)
break;
}
-
- self::$cache_tax_calculator[$postcode.'-'.$this->type] = new TaxCalculator($taxes, $behavior);
+ Cache::store($cache_id, new TaxCalculator($taxes, $behavior));
}
-
- return self::$cache_tax_calculator[$postcode.'-'.$this->type];
+ return Cache::retrieve($cache_id);
}
-}
-
+}
\ No newline at end of file
diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php
index bd5b3b703..b8d943976 100644
--- a/controllers/admin/AdminProductsController.php
+++ b/controllers/admin/AdminProductsController.php
@@ -2660,6 +2660,10 @@ class AdminProductsControllerCore extends AdminController
$product_supplier->id_product = $product->id;
$product_supplier->id_product_attribute = 0;
$product_supplier->id_supplier = $id;
+ if ($this->context->currency->id)
+ $product_supplier->id_currency = (int)$this->context->currency->id;
+ else
+ $product_supplier->id_currency = (int)Configuration::get('PS_CURRENCY_DEFAULT');
$product_supplier->save();
$associated_suppliers[] = $product_supplier;
diff --git a/controllers/front/CmsController.php b/controllers/front/CmsController.php
index a62047b02..2c9793ec4 100644
--- a/controllers/front/CmsController.php
+++ b/controllers/front/CmsController.php
@@ -30,12 +30,13 @@ class CmsControllerCore extends FrontController
public $assignCase;
public $cms;
public $cms_category;
+ public $ssl = false;
public function canonicalRedirection($canonicalURL = '')
{
if (Tools::getValue('live_edit'))
return ;
- if (Validate::isLoadedObject($this->cms) && ($canonicalURL = $this->context->link->getCMSLink($this->cms)))
+ if (Validate::isLoadedObject($this->cms) && ($canonicalURL = $this->context->link->getCMSLink($this->cms, $this->cms->link_rewrite, $this->ssl)))
parent::canonicalRedirection($canonicalURL);
else if (Validate::isLoadedObject($this->cms_category) && ($canonicalURL = $this->context->link->getCMSCategoryLink($this->cms_category)))
parent::canonicalRedirection($canonicalURL);
@@ -47,13 +48,16 @@ class CmsControllerCore extends FrontController
*/
public function init()
{
- parent::init();
-
if ($id_cms = (int)Tools::getValue('id_cms'))
$this->cms = new CMS($id_cms, $this->context->language->id);
else if ($id_cms_category = (int)Tools::getValue('id_cms_category'))
$this->cms_category = new CMSCategory($id_cms_category, $this->context->language->id);
+ if (Configuration::get('PS_SSL_ENABLED') && Tools::getValue('content_only') && Tools::getValue('id_cms') == (int)Configuration::get('PS_CONDITIONS_CMS_ID') && Validate::isLoadedObject($this->cms))
+ $this->ssl = true;
+
+ parent::init();
+
$this->canonicalRedirection();
// assignCase (1 = CMS page, 2 = CMS category)
@@ -120,7 +124,7 @@ class CmsControllerCore extends FrontController
'category' => $this->cms_category, //for backward compatibility
'cms_category' => $this->cms_category,
'sub_category' => $this->cms_category->getSubCategories($this->context->language->id),
- 'cms_pages' => CMS::getCMSPages($this->context->language->id, (int)($this->cms_category->id) ),
+ 'cms_pages' => CMS::getCMSPages($this->context->language->id, (int)($this->cms_category->id), true, (int)$this->context->shop->id),
'path' => ($this->cms_category->id !== 1) ? Tools::getPath($this->cms_category->id, $this->cms_category->name, false, 'CMS') : '',
));
}
diff --git a/controllers/front/ParentOrderController.php b/controllers/front/ParentOrderController.php
index 6fa902bdc..e0672255e 100644
--- a/controllers/front/ParentOrderController.php
+++ b/controllers/front/ParentOrderController.php
@@ -415,6 +415,17 @@ class ParentOrderControllerCore extends FrontController
if (key($customerAddresses) != 0)
$customerAddresses = array_values($customerAddresses);
+ if (!count($customerAddresses))
+ {
+ $bad_delivery = false;
+ if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$this->context->cart->id_address_delivery)) || (!Address::isCountryActiveById((int)$this->context->cart->id_address_invoice)))
+ {
+ $back_url = $this->context->link->getPageLink('order', true, (int)$this->context->language->id, array('step' => Tools::getValue('step'), 'multi-shipping' => (int)Tools::getValue('multi-shipping')));
+ $params = array('multi-shipping' => (int)Tools::getValue('multi-shipping'), 'id_address' => ($bad_delivery ? (int)$this->context->cart->id_address_delivery : (int)$this->context->cart->id_address_invoice), 'back' => $back_url);
+ Tools::redirect($this->context->link->getPageLink('address', true, (int)$this->context->language->id, $params));
+ }
+ }
+
$this->context->smarty->assign(array(
'addresses' => $customerAddresses,
'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList));
@@ -465,16 +476,6 @@ class ParentOrderControllerCore extends FrontController
$address = new Address($this->context->cart->id_address_delivery);
$id_zone = Address::getZoneById($address->id);
$bad_delivery = false;
- if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$this->context->cart->id_address_delivery)) || (!Address::isCountryActiveById((int)$this->context->cart->id_address_invoice)))
- {
- if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1 && Dispatcher::getInstance()->getController() != 'order-opc')
- {
- $back_url = $this->context->link->getPageLink('order', true, (int)$this->context->language->id, array('step' => Tools::getValue('step'), 'multi-shipping' => (int)Tools::getValue('multi-shipping')));
- $params = array('multi-shipping' => (int)Tools::getValue('multi-shipping'), 'id_address' => ($bad_delivery ? (int)$this->context->cart->id_address_delivery : (int)$this->context->cart->id_address_invoice), 'back' => $back_url);
- Tools::redirect($this->context->link->getPageLink('address', true, (int)$this->context->language->id, $params));
- }
- Tools::redirect('index.php?controller=order&step=1');
- }
$carriers = $this->context->cart->simulateCarriersOutput();
$checked = $this->context->cart->simulateCarrierSelectedOutput();
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
@@ -510,7 +511,7 @@ class ParentOrderControllerCore extends FrontController
// TOS
$cms = new CMS(Configuration::get('PS_CONDITIONS_CMS_ID'), $this->context->language->id);
- $this->link_conditions = $this->context->link->getCMSLink($cms, $cms->link_rewrite);
+ $this->link_conditions = $this->context->link->getCMSLink($cms, $cms->link_rewrite, (bool)Configuration::get('PS_SSL_ENABLED'));
if (!strpos($this->link_conditions, '?'))
$this->link_conditions .= '?content_only=1';
else
diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php
index ed2454ab6..46a3a1aff 100644
--- a/controllers/front/ProductController.php
+++ b/controllers/front/ProductController.php
@@ -548,7 +548,7 @@ class ProductControllerCore extends FrontController
$path = Tools::getPath((int)$this->context->shop->id_category, $this->product->name);
$this->context->smarty->assign('path', $path);
- $this->context->smarty->assign('categories', Category::getHomeCategories($this->context->language->id));
+ $this->context->smarty->assign('categories', Category::getHomeCategories($this->context->language->id, true, (int)$this->context->shop->id));
$this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::exec('displayFooterProduct', array('product' => $this->product, 'category' => $this->category))));
}
diff --git a/controllers/front/StoresController.php b/controllers/front/StoresController.php
index ac10c1dc1..33bc1d3d2 100644
--- a/controllers/front/StoresController.php
+++ b/controllers/front/StoresController.php
@@ -279,6 +279,6 @@ class StoresControllerCore extends FrontController
if (!Configuration::get('PS_STORES_SIMPLIFIED'))
$this->addJS(_THEME_JS_DIR_.'stores.js');
$default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'));
- $this->addJS('http://maps.google.com/maps/api/js?sensor=true®ion='.substr($default_country->iso_code, 0, 2));
+ $this->addJS('http'.((Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE')) ? 's' : '').'://maps.google.com/maps/api/js?sensor=true®ion='.substr($default_country->iso_code, 0, 2));
}
}
diff --git a/docs/csv_import/Exemples-Import CSV - 1.4-Addresses-US-Mono.csv b/docs/csv_import/addresses_import.csv
similarity index 100%
rename from docs/csv_import/Exemples-Import CSV - 1.4-Addresses-US-Mono.csv
rename to docs/csv_import/addresses_import.csv
diff --git a/docs/csv_import/alias_import.csv b/docs/csv_import/alias_import.csv
new file mode 100644
index 000000000..77007ea6a
--- /dev/null
+++ b/docs/csv_import/alias_import.csv
@@ -0,0 +1,5 @@
+id;Alias *;Search *;Active (0/1)
+1;ano, anno, nona;nano;1
+2;ipdo, idop, podi;ipod;1
+3;McBook, Mbcook;MacBook;1
+4;Blekin;Belkin;1
diff --git a/docs/csv_import/Exemples-Import CSV - 1.5-Categorie-US-Mono.csv b/docs/csv_import/categories_import.csv
similarity index 100%
rename from docs/csv_import/Exemples-Import CSV - 1.5-Categorie-US-Mono.csv
rename to docs/csv_import/categories_import.csv
diff --git a/docs/csv_import/Exemples-Import CSV - 1.7-Combinations-US-Mono.csv b/docs/csv_import/combinations_import.csv
similarity index 100%
rename from docs/csv_import/Exemples-Import CSV - 1.7-Combinations-US-Mono.csv
rename to docs/csv_import/combinations_import.csv
diff --git a/docs/csv_import/Exemples-Import CSV - 1.1-Customer-US-Mono.csv b/docs/csv_import/customers_import.csv
similarity index 100%
rename from docs/csv_import/Exemples-Import CSV - 1.1-Customer-US-Mono.csv
rename to docs/csv_import/customers_import.csv
diff --git a/docs/csv_import/Exemples-Import CSV - 1.2-Manufacturer-US-Mono.csv b/docs/csv_import/manufacturers_import.csv
similarity index 100%
rename from docs/csv_import/Exemples-Import CSV - 1.2-Manufacturer-US-Mono.csv
rename to docs/csv_import/manufacturers_import.csv
diff --git a/docs/csv_import/Exemples-Import CSV - 1.6-Products-US-Mono.csv b/docs/csv_import/products_import.csv
similarity index 100%
rename from docs/csv_import/Exemples-Import CSV - 1.6-Products-US-Mono.csv
rename to docs/csv_import/products_import.csv
diff --git a/docs/csv_import/Exemples-Import CSV - 1.3-Supplier-US-Mono.csv b/docs/csv_import/suppliers_import.csv
similarity index 100%
rename from docs/csv_import/Exemples-Import CSV - 1.3-Supplier-US-Mono.csv
rename to docs/csv_import/suppliers_import.csv
diff --git a/docs/csv_import/Exemples-Import CSV - 1.9-Details Supply orders-US-Mono.csv b/docs/csv_import/supply_orders_details_import.csv
similarity index 100%
rename from docs/csv_import/Exemples-Import CSV - 1.9-Details Supply orders-US-Mono.csv
rename to docs/csv_import/supply_orders_details_import.csv
diff --git a/docs/csv_import/Exemples-Import CSV - 1.8-Supply orders-US-Mono.csv b/docs/csv_import/supply_orders_import.csv
similarity index 100%
rename from docs/csv_import/Exemples-Import CSV - 1.8-Supply orders-US-Mono.csv
rename to docs/csv_import/supply_orders_import.csv
diff --git a/install-dev/classes/languages.php b/install-dev/classes/languages.php
index f076b39f2..e4c744b9b 100644
--- a/install-dev/classes/languages.php
+++ b/install-dev/classes/languages.php
@@ -136,7 +136,10 @@ class InstallLanguages
}
$args[0] = $translation;
- return call_user_func_array('sprintf', $args);
+ if(count($args) > 1)
+ return call_user_func_array('sprintf', $args);
+ else
+ return $translation;
}
/**
diff --git a/install-dev/fixtures/apple/data/product_supplier.xml b/install-dev/fixtures/apple/data/product_supplier.xml
index 59c4ce5ab..27b34a75f 100644
--- a/install-dev/fixtures/apple/data/product_supplier.xml
+++ b/install-dev/fixtures/apple/data/product_supplier.xml
@@ -8,39 +8,39 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/install-dev/upgrade/sql/1.5.6.1.sql b/install-dev/upgrade/sql/1.5.6.1.sql
index 91d0f9c05..992629875 100644
--- a/install-dev/upgrade/sql/1.5.6.1.sql
+++ b/install-dev/upgrade/sql/1.5.6.1.sql
@@ -8,4 +8,6 @@ UPDATE `PREFIX_orders` SET conversion_rate = 1 WHERE conversion_rate = 0;
ALTER TABLE `PREFIX_cms` ADD `indexation` tinyint(1) UNSIGNED NULL DEFAULT '1' AFTER `active`;
-/* PHP:update_order_messages(); */;
\ No newline at end of file
+/* PHP:update_order_messages(); */;
+
+ALTER TABLE `REFIX_group_reduction` CHANGE `reduction` `reduction` DECIMAL( 4, 4 ) NOT NULL;
\ No newline at end of file
diff --git a/js/admin_carrier_wizard.js b/js/admin_carrier_wizard.js
index fd9c46c89..c0d33cdf3 100644
--- a/js/admin_carrier_wizard.js
+++ b/js/admin_carrier_wizard.js
@@ -393,7 +393,7 @@ function showFees()
//enable only if zone is active
tr = $(this).parent('tr');
validate = $('tr.fees_all td:eq('+$(this).index()+')').hasClass('validated');
- if ($(tr).index() > 2 && $(tr).find('td:eq(1) input').attr('checked') && validate || !$(tr).hasClass('range_sup') || !$(tr).hasClass('range_inf'))
+ if ($(tr).index() > 2 && $(tr).find('td:eq(1) input').prop('checked') && (validate || !$(tr).hasClass('range_sup') || !$(tr).hasClass('range_inf')))
$(this).find('input:text').removeAttr('disabled');
$(this).find('input:text, button').css('background-color', '').css('border-color', '');
diff --git a/localization/gr.xml b/localization/gr.xml
index 474ffc12e..3918f377b 100644
--- a/localization/gr.xml
+++ b/localization/gr.xml
@@ -201,4 +201,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/blockcart/blockcart-json.tpl b/modules/blockcart/blockcart-json.tpl
index 2afe1a214..22646e5c8 100644
--- a/modules/blockcart/blockcart-json.tpl
+++ b/modules/blockcart/blockcart-json.tpl
@@ -61,8 +61,8 @@
{foreach from=$datas key='index' item='data' name='datas'}
{ldelim}
"index": {$index},
- "value": "{$data.value|addslashes|replace: '\\\'':'\''}",
- "truncatedValue": "{$data.value|truncate:28:'...'|addslashes|replace: '\\\'':'\''}"
+ "value": "{Tools::nl2br($data.value|addslashes|replace: '\\\'':'\'')}",
+ "truncatedValue": "{Tools::nl2br($data.value|truncate:28:'...'|addslashes|replace: '\\\'':'\'')}"
{rdelim}{if !$smarty.foreach.datas.last},{/if}
{/foreach}]
{rdelim}{if !$smarty.foreach.customization.last},{/if}
diff --git a/modules/blocklayered/blocklayered.js b/modules/blocklayered/blocklayered.js
index 0edae4fd8..e1ec5b2de 100644
--- a/modules/blocklayered/blocklayered.js
+++ b/modules/blocklayered/blocklayered.js
@@ -230,12 +230,11 @@ function initLayered()
function paginationButton() {
$('#pagination a').not(':hidden').each(function () {
- if ($(this).attr('href').search(/&|\?p=/) == -1) {
- var page = 1;
- }
- else {
- var page = $(this).attr('href').replace(/^.*[&|\?]p=(\d+).*$/, '$1');
- }
+ if ($(this).attr('href').search(/[&|\?]p=/) == -1)
+ var page = 1;
+ else
+ var page = $(this).attr('href').replace(/^.*[&|\?]p=(\d+).*$/, '$1');
+
var location = window.location.href.replace(/#.*$/, '');
$(this).attr('href', location+current_friendly_url.replace(/\/page-(\d+)/, '')+'/page-'+page);
});
diff --git a/modules/blocktopmenu/blocktopmenu.php b/modules/blocktopmenu/blocktopmenu.php
index f22947251..51858836b 100644
--- a/modules/blocktopmenu/blocktopmenu.php
+++ b/modules/blocktopmenu/blocktopmenu.php
@@ -572,7 +572,7 @@ class Blocktopmenu extends Module
switch (substr($item, 0, strlen($value[1])))
{
case 'CAT':
- $this->getCategory((int)$id);
+ $this->getCategory($id, $id_lang, $id_shop);
break;
case 'PRD':
@@ -687,9 +687,7 @@ class Blocktopmenu extends Module
if (isset($children) && count($children))
foreach ($children as $child)
- {
$this->getCategoryOption((int)$child['id_category'], (int)$id_lang, (int)$child['id_shop']);
- }
}
private function getCategory($id_category, $id_lang = false, $id_shop = false)
diff --git a/modules/blockwishlist/WishList.php b/modules/blockwishlist/WishList.php
index 7ab58cc44..23e57cdbe 100644
--- a/modules/blockwishlist/WishList.php
+++ b/modules/blockwishlist/WishList.php
@@ -171,6 +171,8 @@ class WishList extends ObjectModel
*/
public static function getByIdCustomer($id_customer)
{
+ if (!Validate::isUnsignedId($id_customer))
+ die (Tools::displayError());
if (Shop::getContextShopID())
$shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID();
elseif (Shop::getContextShopGroupID())
@@ -178,14 +180,18 @@ class WishList extends ObjectModel
else
$shop_restriction = '';
- if (!Validate::isUnsignedId($id_customer))
- die (Tools::displayError());
- return (Db::getInstance()->executeS('
- SELECT w.`id_wishlist`, w.`name`, w.`token`, w.`date_add`, w.`date_upd`, w.`counter`
- FROM `'._DB_PREFIX_.'wishlist` w
- WHERE `id_customer` = '.(int)($id_customer).'
- '.$shop_restriction.'
- ORDER BY w.`name` ASC'));
+ $cache_id = 'WhishList::getByIdCustomer_'.(int)$id_customer.'-'.(int)Shop::getContextShopID().'-'.(int)Shop::getContextShopGroupID();
+ if (!Cache::isStored($cache_id))
+ {
+ $result = Db::getInstance()->executeS('
+ SELECT w.`id_wishlist`, w.`name`, w.`token`, w.`date_add`, w.`date_upd`, w.`counter`
+ FROM `'._DB_PREFIX_.'wishlist` w
+ WHERE `id_customer` = '.(int)($id_customer).'
+ '.$shop_restriction.'
+ ORDER BY w.`name` ASC');
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
public static function refreshWishList($id_wishlist)
diff --git a/modules/blockwishlist/js/ajax-wishlist.js b/modules/blockwishlist/js/ajax-wishlist.js
index 8642ce759..8e748dd9a 100644
--- a/modules/blockwishlist/js/ajax-wishlist.js
+++ b/modules/blockwishlist/js/ajax-wishlist.js
@@ -58,7 +58,7 @@ function WishlistCart(id, action, id_product, id_product_attribute, quantity)
if($('#' + id).length != 0)
{
$('#' + id).slideUp('normal');
- document.getElementById(id).innerHTML = data;
+ $('#' + id).html(data);
$('#' + id).slideDown('normal');
}
}
@@ -81,7 +81,7 @@ function WishlistChangeDefault(id, id_wishlist)
success: function(data)
{
$('#' + id).slideUp('normal');
- document.getElementById(id).innerHTML = data;
+ $('#' + id).html(data);
$('#' + id).slideDown('normal');
}
});
@@ -147,7 +147,7 @@ function WishlistManage(id, id_wishlist)
success: function(data)
{
$('#' + id).hide();
- document.getElementById(id).innerHTML = data;
+ $('#' + id).html(data);
$('#' + id).fadeIn('slow');
}
});
diff --git a/modules/crossselling/crossselling.php b/modules/crossselling/crossselling.php
index ec157f73d..9381da964 100755
--- a/modules/crossselling/crossselling.php
+++ b/modules/crossselling/crossselling.php
@@ -43,9 +43,6 @@ class CrossSelling extends Module
$this->displayName = $this->l('Cross Selling');
$this->description = $this->l('Customers who bought this product also bought:');
-
- if (!$this->isRegisteredInHook('header'))
- $this->registerHook('header');
}
public function install()
diff --git a/modules/crossselling/upgrade/install-0.8.php b/modules/crossselling/upgrade/install-0.8.php
new file mode 100644
index 000000000..1ee79f5e5
--- /dev/null
+++ b/modules/crossselling/upgrade/install-0.8.php
@@ -0,0 +1,11 @@
+isRegisteredInHook('header'))
+ return $object->registerHook('header');
+ return true;
+}
diff --git a/modules/loyalty/LoyaltyModule.php b/modules/loyalty/LoyaltyModule.php
index cb2c51974..7dc030a2b 100644
--- a/modules/loyalty/LoyaltyModule.php
+++ b/modules/loyalty/LoyaltyModule.php
@@ -101,9 +101,9 @@ class LoyaltyModule extends ObjectModel
{
$cartProductsNew['id_product'] = (int)$newProduct->id;
if ($taxesEnabled == PS_TAX_EXC)
- $cartProductsNew['price'] = number_format($newProduct->getPrice(false, (int)$newProduct->getDefaultIdProductAttribute()), 2, '.', '');
+ $cartProductsNew['price'] = number_format($newProduct->getPrice(false, (int)$newProduct->getIdProductAttributeMostExpensive()), 2, '.', '');
else
- $cartProductsNew['price_wt'] = number_format($newProduct->getPrice(true, (int)$newProduct->getDefaultIdProductAttribute()), 2, '.', '');
+ $cartProductsNew['price_wt'] = number_format($newProduct->getPrice(true, (int)$newProduct->getIdProductAttributeMostExpensive()), 2, '.', '');
$cartProductsNew['cart_quantity'] = 1;
$cartProducts[] = $cartProductsNew;
}
diff --git a/modules/loyalty/config.xml b/modules/loyalty/config.xml
index eed08a452..5ae4ee2f0 100755
--- a/modules/loyalty/config.xml
+++ b/modules/loyalty/config.xml
@@ -1,12 +1,12 @@
loyalty
-
+
-
+
- Are you sure you want to delete all loyalty points and customer history?
+ Cette action effacera tous les points de fidélité et l'historique des points de tous vos clients, êtes vous sûr ?
1
0
diff --git a/modules/loyalty/loyalty.php b/modules/loyalty/loyalty.php
index 96b71f57e..640c08968 100644
--- a/modules/loyalty/loyalty.php
+++ b/modules/loyalty/loyalty.php
@@ -453,7 +453,7 @@ class Loyalty extends Module
$points = (int)LoyaltyModule::getNbPointsByPrice(
$product->getPrice(
Product::getTaxCalculationMethod() == PS_TAX_EXC ? false : true,
- (int)$product->getDefaultIdProductAttribute()
+ (int)$product->getIdProductAttributeMostExpensive()
)
);
diff --git a/modules/loyalty/views/templates/hook/product.tpl b/modules/loyalty/views/templates/hook/product.tpl
index 63cd24db3..36d6c55ac 100644
--- a/modules/loyalty/views/templates/hook/product.tpl
+++ b/modules/loyalty/views/templates/hook/product.tpl
@@ -39,7 +39,7 @@ $(document).ready(function() {
if (typeof(productPrice) == 'undefined' || typeof(productPriceWithoutReduction) == 'undefined')
return;
- var points = Math.round(productPrice / point_rate);
+ var points = {$points};
var total_points = points_in_cart + points;
var voucher = total_points * point_value;
if (!none_award && productPriceWithoutReduction != productPrice) {
diff --git a/modules/mailalerts/config.xml b/modules/mailalerts/config.xml
index 98984a992..699578ed4 100755
--- a/modules/mailalerts/config.xml
+++ b/modules/mailalerts/config.xml
@@ -2,7 +2,7 @@
mailalerts
-
+
diff --git a/modules/mailalerts/mailalerts.php b/modules/mailalerts/mailalerts.php
index 57ed8cb91..8dddab040 100644
--- a/modules/mailalerts/mailalerts.php
+++ b/modules/mailalerts/mailalerts.php
@@ -46,7 +46,7 @@ class MailAlerts extends Module
{
$this->name = 'mailalerts';
$this->tab = 'administration';
- $this->version = '2.7';
+ $this->version = '2.8';
$this->author = 'PrestaShop';
$this->need_instance = 0;
@@ -383,7 +383,7 @@ class MailAlerts extends Module
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
'{invoice_phone}' => $invoice->phone ? $invoice->phone : $invoice->phone_mobile,
'{invoice_other}' => $invoice->other,
- '{order_name}' => sprintf('%06d', $order->id),
+ '{order_name}' => $order->reference,
'{shop_name}' => $configuration['PS_SHOP_NAME'],
'{date}' => $order_date_text,
'{carrier}' => (($carrier->name == '0') ? $configuration['PS_SHOP_NAME'] : $carrier->name),
diff --git a/modules/productcomments/ProductComment.php b/modules/productcomments/ProductComment.php
index cb7aa8994..5887357b8 100644
--- a/modules/productcomments/ProductComment.php
+++ b/modules/productcomments/ProductComment.php
@@ -97,18 +97,24 @@ class ProductComment extends ObjectModel
if ($n != null && $n <= 0)
$n = 5;
- return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
- SELECT pc.`id_product_comment`,
- (SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment` AND pcu.`usefulness` = 1) as total_useful,
- (SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment`) as total_advice, '.
- ((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcuc WHERE pcuc.`id_product_comment` = pc.`id_product_comment` AND pcuc.id_customer = '.(int)$id_customer.') as customer_advice, ' : '').
- ((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_report` pcrc WHERE pcrc.`id_product_comment` = pc.`id_product_comment` AND pcrc.id_customer = '.(int)$id_customer.') as customer_report, ' : '').'
- IF(c.id_customer, CONCAT(c.`firstname`, \' \', LEFT(c.`lastname`, 1)), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pc.title
- FROM `'._DB_PREFIX_.'product_comment` pc
- LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = pc.`id_customer`
- WHERE pc.`id_product` = '.(int)($id_product).($validate == '1' ? ' AND pc.`validate` = 1' : '').'
- ORDER BY pc.`date_add` DESC
- '.($n ? 'LIMIT '.(int)(($p - 1) * $n).', '.(int)($n) : ''));
+ $cache_id = 'ProductComment::getByProduct_'.(int)$id_product.'-'.(int)$p.'-'.(int)$n.'-'.(int)$id_customer.'-'.(bool)$validate;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
+ SELECT pc.`id_product_comment`,
+ (SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment` AND pcu.`usefulness` = 1) as total_useful,
+ (SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment`) as total_advice, '.
+ ((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcuc WHERE pcuc.`id_product_comment` = pc.`id_product_comment` AND pcuc.id_customer = '.(int)$id_customer.') as customer_advice, ' : '').
+ ((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_report` pcrc WHERE pcrc.`id_product_comment` = pc.`id_product_comment` AND pcrc.id_customer = '.(int)$id_customer.') as customer_report, ' : '').'
+ IF(c.id_customer, CONCAT(c.`firstname`, \' \', LEFT(c.`lastname`, 1)), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pc.title
+ FROM `'._DB_PREFIX_.'product_comment` pc
+ LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = pc.`id_customer`
+ WHERE pc.`id_product` = '.(int)($id_product).($validate == '1' ? ' AND pc.`validate` = 1' : '').'
+ ORDER BY pc.`date_add` DESC
+ '.($n ? 'LIMIT '.(int)(($p - 1) * $n).', '.(int)($n) : ''));
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -118,18 +124,24 @@ class ProductComment extends ObjectModel
*/
public static function getByCustomer($id_product, $id_customer, $get_last = false, $id_guest = false)
{
- $results = Db::getInstance()->executeS('
- SELECT *
- FROM `'._DB_PREFIX_.'product_comment` pc
- WHERE pc.`id_product` = '.(int)$id_product.'
- AND '.(!$id_guest ? 'pc.`id_customer` = '.(int)$id_customer : 'pc.`id_guest` = '.(int)$id_guest).'
- ORDER BY pc.`date_add` DESC '
- .($get_last ? 'LIMIT 1' : '')
- );
+ $cache_id = 'ProductComment::getByCustomer_'.(int)$id_product.'-'.(int)$id_customer.'-'.(bool)$get_last.'-'.(int)$id_guest;
+ if (!Cache::isStored($cache_id))
+ {
+ $results = Db::getInstance()->executeS('
+ SELECT *
+ FROM `'._DB_PREFIX_.'product_comment` pc
+ WHERE pc.`id_product` = '.(int)$id_product.'
+ AND '.(!$id_guest ? 'pc.`id_customer` = '.(int)$id_customer : 'pc.`id_guest` = '.(int)$id_guest).'
+ ORDER BY pc.`date_add` DESC '
+ .($get_last ? 'LIMIT 1' : '')
+ );
- if ($get_last)
- $results = array_shift($results);
- return $results;
+ if ($get_last && count($results))
+ $results = array_shift($results);
+
+ Cache::store($cache_id, $results);
+ }
+ return Cache::retrieve($cache_id);
}
/**
@@ -202,12 +214,16 @@ class ProductComment extends ObjectModel
if (!Validate::isUnsignedId($id_product))
die(Tools::displayError());
$validate = (int)Configuration::get('PRODUCT_COMMENTS_MODERATE');
- if (($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
- SELECT COUNT(`id_product_comment`) AS "nbr"
- FROM `'._DB_PREFIX_.'product_comment` pc
- WHERE `id_product` = '.(int)($id_product).($validate == '1' ? ' AND `validate` = 1' : ''))) === false)
- return false;
- return (int)($result['nbr']);
+ $cache_id = 'ProductComment::getCommentNumber_'.(int)$id_product.'-'.$validate;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
+ SELECT COUNT(`id_product_comment`) AS "nbr"
+ FROM `'._DB_PREFIX_.'product_comment` pc
+ WHERE `id_product` = '.(int)($id_product).($validate == '1' ? ' AND `validate` = 1' : ''));
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/modules/productcomments/ProductCommentCriterion.php b/modules/productcomments/ProductCommentCriterion.php
index dc8f668ba..e46775c0c 100644
--- a/modules/productcomments/ProductCommentCriterion.php
+++ b/modules/productcomments/ProductCommentCriterion.php
@@ -159,26 +159,33 @@ class ProductCommentCriterion extends ObjectModel
$table = '_shop';
$alias = 'ps';
}
- return Db::getInstance()->executeS('
- SELECT pcc.`id_product_comment_criterion`, pccl.`name`
- FROM `'._DB_PREFIX_.'product_comment_criterion` pcc
- LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_lang` pccl
- ON (pcc.id_product_comment_criterion = pccl.id_product_comment_criterion)
- LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_product` pccp
- ON (pcc.`id_product_comment_criterion` = pccp.`id_product_comment_criterion` AND pccp.`id_product` = '.(int)$id_product.')
- LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_category` pccc
- ON (pcc.`id_product_comment_criterion` = pccc.`id_product_comment_criterion`)
- LEFT JOIN `'._DB_PREFIX_.'product'.$table.'` '.$alias.'
- ON ('.$alias.'.id_category_default = pccc.id_category AND '.$alias.'.id_product = '.(int)$id_product.')
- WHERE pccl.`id_lang` = '.(int)($id_lang).'
- AND (
- pccp.id_product IS NOT NULL
- OR ps.id_product IS NOT NULL
- OR pcc.id_product_comment_criterion_type = 1
- )
- AND pcc.active = 1
- GROUP BY pcc.id_product_comment_criterion
- ');
+
+ $cache_id = 'ProductCommentCriterion::getByProduct_'.(int)$id_product.'-'.(int)$id_lang;
+ if (!Cache::isStored($cache_id))
+ {
+ $result = Db::getInstance()->executeS('
+ SELECT pcc.`id_product_comment_criterion`, pccl.`name`
+ FROM `'._DB_PREFIX_.'product_comment_criterion` pcc
+ LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_lang` pccl
+ ON (pcc.id_product_comment_criterion = pccl.id_product_comment_criterion)
+ LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_product` pccp
+ ON (pcc.`id_product_comment_criterion` = pccp.`id_product_comment_criterion` AND pccp.`id_product` = '.(int)$id_product.')
+ LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_category` pccc
+ ON (pcc.`id_product_comment_criterion` = pccc.`id_product_comment_criterion`)
+ LEFT JOIN `'._DB_PREFIX_.'product'.$table.'` '.$alias.'
+ ON ('.$alias.'.id_category_default = pccc.id_category AND '.$alias.'.id_product = '.(int)$id_product.')
+ WHERE pccl.`id_lang` = '.(int)($id_lang).'
+ AND (
+ pccp.id_product IS NOT NULL
+ OR ps.id_product IS NOT NULL
+ OR pcc.id_product_comment_criterion_type = 1
+ )
+ AND pcc.active = 1
+ GROUP BY pcc.id_product_comment_criterion
+ ');
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
}
/**
diff --git a/modules/productcomments/config.xml b/modules/productcomments/config.xml
index c9413f84f..e45f34f8e 100755
--- a/modules/productcomments/config.xml
+++ b/modules/productcomments/config.xml
@@ -1,9 +1,9 @@
productcomments
-
+
-
+
1
diff --git a/modules/productcomments/productcomments.tpl b/modules/productcomments/productcomments.tpl
index 710b6665c..5e3c16fb3 100644
--- a/modules/productcomments/productcomments.tpl
+++ b/modules/productcomments/productcomments.tpl
@@ -98,6 +98,7 @@ var moderation_active = {$moderation_active};
{/if}
-
+
{if $group_use_tax}
{convertPriceWithCurrency price=$product.unit_price_tax_incl currency=$currency}
{else}
@@ -195,7 +195,7 @@
-
+
{if isset($customizedDatas.$productId.$productAttributeId)}
{if $group_use_tax}
{convertPriceWithCurrency price=$product.total_customization_wt currency=$currency}
@@ -274,7 +274,7 @@
{/if}
-
+
{if $group_use_tax}
{convertPriceWithCurrency price=$product.unit_price_tax_incl currency=$currency}
{else}
@@ -283,7 +283,7 @@
-
+
{if $group_use_tax}
{convertPriceWithCurrency price=$product.total_price_tax_incl currency=$currency}
{else}
diff --git a/themes/default/order-opc-new-account.tpl b/themes/default/order-opc-new-account.tpl
index 4e31a068c..0f8f2acbc 100644
--- a/themes/default/order-opc-new-account.tpl
+++ b/themes/default/order-opc-new-account.tpl
@@ -316,7 +316,7 @@
{elseif $field_name eq "lastname"}
{l s='Last name'} *
-
+
{elseif $field_name eq "address1"}
diff --git a/tools/profiling/Controller.php b/tools/profiling/Controller.php
index 5fee49cb2..82ba93643 100644
--- a/tools/profiling/Controller.php
+++ b/tools/profiling/Controller.php
@@ -466,13 +466,19 @@ abstract class Controller extends ControllerCore
echo 'Useless GROUP BY need to be removed ';
}
}
- echo '
-
-
';
$queries = Db::getInstance()->uniqQueries;
arsort($queries);
+ $count = count(Db::getInstance()->uniqQueries);
+ foreach ($queries as $q => &$nb)
+ if ($nb == 1)
+ $count--;
+ if ($count)
+ echo '
+
+
';
foreach ($queries as $q => $nb)
- echo $hr.'
getQueryColor($nb).'>'.$nb.' '.$q;
+ if($nb > 1)
+ echo $hr.'
getQueryColor($nb).'>'.$nb.' '.$q;
echo '
';
diff --git a/translations/fr.gzip b/translations/fr.gzip
deleted file mode 100644
index 960058ab7..000000000
Binary files a/translations/fr.gzip and /dev/null differ