// 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)
|
||||
{
|
||||
$out = $this->_getFormatDB($id_country);
|
||||
|
||||
if (strlen(trim($out)) == 0)
|
||||
if (empty($out))
|
||||
$out = $this->_getFormatDB(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
return $out;
|
||||
}
|
||||
|
||||
protected function _getFormatDB($id_country)
|
||||
{
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT format
|
||||
FROM `'._DB_PREFIX_.$this->def['table'].'`
|
||||
WHERE `id_country` = '.(int)($id_country));
|
||||
|
||||
return isset($result['format']) ? trim($result['format']) : '';
|
||||
if (!Cache::isStored('AddressFormat::_getFormatDB'.$id_country))
|
||||
{
|
||||
$format = Db::getInstance()->getValue('
|
||||
SELECT format
|
||||
FROM `'._DB_PREFIX_.$this->def['table'].'`
|
||||
WHERE `id_country` = '.(int)$id_country);
|
||||
Cache::store('AddressFormat::_getFormatDB'.$id_country, trim($format));
|
||||
}
|
||||
return Cache::retrieve('AddressFormat::_getFormatDB'.$id_country);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+38
-31
@@ -277,39 +277,43 @@ class CartCore extends ObjectModel
|
||||
// If the cart has not been saved, then there can't be any cart rule applied
|
||||
if (!CartRule::isFeatureActive() || !$this->id)
|
||||
return array();
|
||||
|
||||
$total_products_ti = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS);
|
||||
$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)
|
||||
|
||||
if (!Cache::isStored('Cart::getCartRules'.$this->id))
|
||||
{
|
||||
$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);
|
||||
$total_products_ti = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS);
|
||||
$total_products_te = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||
$shipping_ti = $this->getTotalShippingCost();
|
||||
$shipping_te = $this->getTotalShippingCost(null, false);
|
||||
|
||||
// Retro compatibility < 1.5.0.2
|
||||
$row['id_discount'] = $row['id_cart_rule'];
|
||||
$row['description'] = $row['name'];
|
||||
$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);
|
||||
$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 $result;
|
||||
return Cache::retrieve('Cart::getCartRules'.$this->id);
|
||||
}
|
||||
|
||||
public function getDiscountsCustomer($id_cart_rule)
|
||||
@@ -701,7 +705,9 @@ class CartCore extends ObjectModel
|
||||
'id_cart' => (int)$this->id
|
||||
)))
|
||||
return false;
|
||||
|
||||
|
||||
Cache::clean('Cart::getCartRules'.$this->id);
|
||||
|
||||
if ((int)$cartRule->gift_product)
|
||||
return $this->updateQty(1, $cartRule->gift_product);
|
||||
|
||||
@@ -1016,6 +1022,7 @@ class CartCore extends ObjectModel
|
||||
|
||||
public function removeCartRule($id_cart_rule)
|
||||
{
|
||||
Cache::clean('Cart::getCartRules'.$this->id);
|
||||
return Db::getInstance()->Execute(
|
||||
'DELETE FROM `'._DB_PREFIX_.'cart_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`
|
||||
WHERE cp.`id_category` = '.(int)$this->id
|
||||
.($active ? ' AND p.`active` = 1' : '')
|
||||
.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '').
|
||||
' GROUP BY p.id_product';
|
||||
.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '');
|
||||
|
||||
if ($random === true)
|
||||
{
|
||||
|
||||
+15
-3
@@ -223,6 +223,8 @@ abstract class ModuleCore
|
||||
}
|
||||
$this->id = Db::getInstance()->Insert_ID();
|
||||
|
||||
Cache::clean('Module::isInstalled'.$this->name);
|
||||
|
||||
// Enable the module for all shops
|
||||
$this->enable(true);
|
||||
|
||||
@@ -457,7 +459,13 @@ abstract class ModuleCore
|
||||
Group::truncateRestrictionsByModule($this->id);
|
||||
|
||||
// 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)
|
||||
{
|
||||
Db::getInstance()->executeS('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = \''.pSQL($module_name).'\'');
|
||||
return (bool)Db::getInstance()->NumRows();
|
||||
if (!Cache::isStored('Module::isInstalled'.$module_name))
|
||||
{
|
||||
$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)
|
||||
|
||||
Reference in New Issue
Block a user