// A few dozens queries less on every pages...
This commit is contained in:
@@ -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))
|
||||||
SELECT format
|
{
|
||||||
FROM `'._DB_PREFIX_.$this->def['table'].'`
|
$format = Db::getInstance()->getValue('
|
||||||
WHERE `id_country` = '.(int)($id_country));
|
SELECT format
|
||||||
|
FROM `'._DB_PREFIX_.$this->def['table'].'`
|
||||||
return isset($result['format']) ? trim($result['format']) : '';
|
WHERE `id_country` = '.(int)$id_country);
|
||||||
|
Cache::store('AddressFormat::_getFormatDB'.$id_country, trim($format));
|
||||||
|
}
|
||||||
|
return Cache::retrieve('AddressFormat::_getFormatDB'.$id_country);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+36
-29
@@ -278,38 +278,42 @@ class CartCore extends ObjectModel
|
|||||||
if (!CartRule::isFeatureActive() || !$this->id)
|
if (!CartRule::isFeatureActive() || !$this->id)
|
||||||
return array();
|
return array();
|
||||||
|
|
||||||
$total_products_ti = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS);
|
if (!Cache::isStored('Cart::getCartRules'.$this->id))
|
||||||
$total_products_te = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
|
||||||
$shipping_ti = $this->getTotalShippingCost();
|
|
||||||
$shipping_te = $this->getTotalShippingCost(null, false);
|
|
||||||
|
|
||||||
$result = Db::getInstance()->executeS('
|
|
||||||
SELECT *
|
|
||||||
FROM `'._DB_PREFIX_.'cart_cart_rule` cd
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'cart_rule` cr ON cd.`id_cart_rule` = cr.`id_cart_rule`
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'cart_rule_lang` crl ON (
|
|
||||||
cd.`id_cart_rule` = crl.`id_cart_rule`
|
|
||||||
AND crl.id_lang = '.(int)$this->id_lang.'
|
|
||||||
)
|
|
||||||
WHERE `id_cart` = '.(int)$this->id
|
|
||||||
);
|
|
||||||
|
|
||||||
// Define virtual context to prevent case where the cart is not the in the global context
|
|
||||||
$virtual_context = Context::getContext()->cloneContext();
|
|
||||||
$virtual_context->cart = $this;
|
|
||||||
|
|
||||||
foreach ($result as &$row)
|
|
||||||
{
|
{
|
||||||
$row['obj'] = new CartRule($row['id_cart_rule'], (int)$this->id_lang);
|
$total_products_ti = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS);
|
||||||
$row['value_real'] = $row['obj']->getContextualValue(true, $virtual_context);
|
$total_products_te = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||||
$row['value_tax_exc'] = $row['obj']->getContextualValue(false, $virtual_context);
|
$shipping_ti = $this->getTotalShippingCost();
|
||||||
|
$shipping_te = $this->getTotalShippingCost(null, false);
|
||||||
|
|
||||||
// Retro compatibility < 1.5.0.2
|
$result = Db::getInstance()->executeS('
|
||||||
$row['id_discount'] = $row['id_cart_rule'];
|
SELECT *
|
||||||
$row['description'] = $row['name'];
|
FROM `'._DB_PREFIX_.'cart_cart_rule` cd
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'cart_rule` cr ON cd.`id_cart_rule` = cr.`id_cart_rule`
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'cart_rule_lang` crl ON (
|
||||||
|
cd.`id_cart_rule` = crl.`id_cart_rule`
|
||||||
|
AND crl.id_lang = '.(int)$this->id_lang.'
|
||||||
|
)
|
||||||
|
WHERE `id_cart` = '.(int)$this->id
|
||||||
|
);
|
||||||
|
|
||||||
|
// Define virtual context to prevent case where the cart is not the in the global context
|
||||||
|
$virtual_context = Context::getContext()->cloneContext();
|
||||||
|
$virtual_context->cart = $this;
|
||||||
|
|
||||||
|
foreach ($result as &$row)
|
||||||
|
{
|
||||||
|
$row['obj'] = new CartRule($row['id_cart_rule'], (int)$this->id_lang);
|
||||||
|
$row['value_real'] = $row['obj']->getContextualValue(true, $virtual_context);
|
||||||
|
$row['value_tax_exc'] = $row['obj']->getContextualValue(false, $virtual_context);
|
||||||
|
|
||||||
|
// Retro compatibility < 1.5.0.2
|
||||||
|
$row['id_discount'] = $row['id_cart_rule'];
|
||||||
|
$row['description'] = $row['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Cache::store('Cart::getCartRules'.$this->id, $result);
|
||||||
}
|
}
|
||||||
|
return Cache::retrieve('Cart::getCartRules'.$this->id);
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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