// A few dozens queries less on every pages...
This commit is contained in:
1 parent
c7d5e920a6
commit
e102ae2928
4 files changed
+32
-13
No files matched your search
@@ -508,20 +508,21 @@ class AddressFormatCore extends ObjectModel
|
|||||||
public function getFormat($id_country)
|
public function getFormat($id_country)
|
||||||
{
|
{
|
||||||
$out = $this->_getFormatDB($id_country);
|
$out = $this->_getFormatDB($id_country);
|
||||||
|
if (empty($out))
|
||||||
if (strlen(trim($out)) == 0)
|
|
||||||
$out = $this->_getFormatDB(Configuration::get('PS_COUNTRY_DEFAULT'));
|
$out = $this->_getFormatDB(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _getFormatDB($id_country)
|
protected function _getFormatDB($id_country)
|
||||||
{
|
{
|
||||||
$result = Db::getInstance()->getRow('
|
if (!Cache::isStored('AddressFormat::_getFormatDB'.$id_country))
|
||||||
|
{
|
||||||
|
$format = Db::getInstance()->getValue('
|
||||||
SELECT format
|
SELECT format
|
||||||
FROM `'._DB_PREFIX_.$this->def['table'].'`
|
FROM `'._DB_PREFIX_.$this->def['table'].'`
|
||||||
WHERE `id_country` = '.(int)($id_country));
|
WHERE `id_country` = '.(int)$id_country);
|
||||||
|
Cache::store('AddressFormat::_getFormatDB'.$id_country, trim($format));
|
||||||
return isset($result['format']) ? trim($result['format']) : '';
|
}
|
||||||
|
return Cache::retrieve('AddressFormat::_getFormatDB'.$id_country);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+8
-1
@@ -278,6 +278,8 @@ class CartCore extends ObjectModel
|
|||||||
if (!CartRule::isFeatureActive() || !$this->id)
|
if (!CartRule::isFeatureActive() || !$this->id)
|
||||||
return array();
|
return array();
|
||||||
|
|
||||||
|
if (!Cache::isStored('Cart::getCartRules'.$this->id))
|
||||||
|
{
|
||||||
$total_products_ti = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS);
|
$total_products_ti = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS);
|
||||||
$total_products_te = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
$total_products_te = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||||
$shipping_ti = $this->getTotalShippingCost();
|
$shipping_ti = $this->getTotalShippingCost();
|
||||||
@@ -309,7 +311,9 @@ class CartCore extends ObjectModel
|
|||||||
$row['description'] = $row['name'];
|
$row['description'] = $row['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
Cache::store('Cart::getCartRules'.$this->id, $result);
|
||||||
|
}
|
||||||
|
return Cache::retrieve('Cart::getCartRules'.$this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDiscountsCustomer($id_cart_rule)
|
public function getDiscountsCustomer($id_cart_rule)
|
||||||
@@ -702,6 +706,8 @@ class CartCore extends ObjectModel
|
|||||||
)))
|
)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Cache::clean('Cart::getCartRules'.$this->id);
|
||||||
|
|
||||||
if ((int)$cartRule->gift_product)
|
if ((int)$cartRule->gift_product)
|
||||||
return $this->updateQty(1, $cartRule->gift_product);
|
return $this->updateQty(1, $cartRule->gift_product);
|
||||||
|
|
||||||
@@ -1016,6 +1022,7 @@ class CartCore extends ObjectModel
|
|||||||
|
|
||||||
public function removeCartRule($id_cart_rule)
|
public function removeCartRule($id_cart_rule)
|
||||||
{
|
{
|
||||||
|
Cache::clean('Cart::getCartRules'.$this->id);
|
||||||
return Db::getInstance()->Execute(
|
return Db::getInstance()->Execute(
|
||||||
'DELETE FROM `'._DB_PREFIX_.'cart_cart_rule`
|
'DELETE FROM `'._DB_PREFIX_.'cart_cart_rule`
|
||||||
WHERE `id_cart_rule` = '.(int)$id_cart_rule.'
|
WHERE `id_cart_rule` = '.(int)$id_cart_rule.'
|
||||||
|
|||||||
@@ -663,8 +663,7 @@ class CategoryCore extends ObjectModel
|
|||||||
ON m.`id_manufacturer` = p.`id_manufacturer`
|
ON m.`id_manufacturer` = p.`id_manufacturer`
|
||||||
WHERE cp.`id_category` = '.(int)$this->id
|
WHERE cp.`id_category` = '.(int)$this->id
|
||||||
.($active ? ' AND p.`active` = 1' : '')
|
.($active ? ' AND p.`active` = 1' : '')
|
||||||
.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '').
|
.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '');
|
||||||
' GROUP BY p.id_product';
|
|
||||||
|
|
||||||
if ($random === true)
|
if ($random === true)
|
||||||
{
|
{
|
||||||
|
|||||||
+15
-3
@@ -223,6 +223,8 @@ abstract class ModuleCore
|
|||||||
}
|
}
|
||||||
$this->id = Db::getInstance()->Insert_ID();
|
$this->id = Db::getInstance()->Insert_ID();
|
||||||
|
|
||||||
|
Cache::clean('Module::isInstalled'.$this->name);
|
||||||
|
|
||||||
// Enable the module for all shops
|
// Enable the module for all shops
|
||||||
$this->enable(true);
|
$this->enable(true);
|
||||||
|
|
||||||
@@ -457,7 +459,13 @@ abstract class ModuleCore
|
|||||||
Group::truncateRestrictionsByModule($this->id);
|
Group::truncateRestrictionsByModule($this->id);
|
||||||
|
|
||||||
// Uninstall the module
|
// Uninstall the module
|
||||||
return Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'module` WHERE `id_module` = '.(int)$this->id);
|
if (Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'module` WHERE `id_module` = '.(int)$this->id))
|
||||||
|
{
|
||||||
|
Cache::clean('Module::isInstalled'.$this->name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1437,8 +1445,12 @@ abstract class ModuleCore
|
|||||||
|
|
||||||
public static function isInstalled($module_name)
|
public static function isInstalled($module_name)
|
||||||
{
|
{
|
||||||
Db::getInstance()->executeS('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = \''.pSQL($module_name).'\'');
|
if (!Cache::isStored('Module::isInstalled'.$module_name))
|
||||||
return (bool)Db::getInstance()->NumRows();
|
{
|
||||||
|
$id_module = Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = \''.pSQL($module_name).'\'');
|
||||||
|
Cache::store('Module::isInstalled'.$module_name, (bool)$id_module);
|
||||||
|
}
|
||||||
|
return Cache::retrieve('Module::isInstalled'.$module_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isRegisteredInHook($hook)
|
public function isRegisteredInHook($hook)
|
||||||
|
|||||||
Reference in new issue
Block a user