// Performance optimizations
This commit is contained in:
+6
-3
@@ -1799,8 +1799,8 @@ class CartCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public function getDeliveryOptionList(Country $default_country = null, $flush = false)
|
public function getDeliveryOptionList(Country $default_country = null, $flush = false)
|
||||||
{
|
{
|
||||||
static $cache = false;
|
static $cache = null;
|
||||||
if ($cache !== false && !$flush)
|
if ($cache !== null && !$flush)
|
||||||
return $cache;
|
return $cache;
|
||||||
|
|
||||||
$delivery_option_list = array();
|
$delivery_option_list = array();
|
||||||
@@ -1828,7 +1828,10 @@ class CartCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
// No carriers available
|
// No carriers available
|
||||||
if (count($package['carrier_list']) == 1 && current($package['carrier_list']) == 0)
|
if (count($package['carrier_list']) == 1 && current($package['carrier_list']) == 0)
|
||||||
return array();
|
{
|
||||||
|
$cache = array();
|
||||||
|
return $cache;
|
||||||
|
}
|
||||||
|
|
||||||
$carriers_price[$id_address][$id_package] = array();
|
$carriers_price[$id_address][$id_package] = array();
|
||||||
|
|
||||||
|
|||||||
@@ -200,7 +200,11 @@ class CombinationCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function isFeatureActive()
|
public static function isFeatureActive()
|
||||||
{
|
{
|
||||||
return Configuration::get('PS_COMBINATION_FEATURE_ACTIVE');
|
static $feature_active = null;
|
||||||
|
|
||||||
|
if ($feature_active === null)
|
||||||
|
$feature_active = Configuration::get('PS_COMBINATION_FEATURE_ACTIVE');
|
||||||
|
return $feature_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+7
-3
@@ -35,6 +35,8 @@ class LinkCore
|
|||||||
public $protocol_link;
|
public $protocol_link;
|
||||||
public $protocol_content;
|
public $protocol_content;
|
||||||
|
|
||||||
|
protected $ssl_enable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor (initialization only)
|
* Constructor (initialization only)
|
||||||
*/
|
*/
|
||||||
@@ -49,6 +51,8 @@ class LinkCore
|
|||||||
define('_PS_BASE_URL_', Tools::getShopDomain(true));
|
define('_PS_BASE_URL_', Tools::getShopDomain(true));
|
||||||
if (!defined('_PS_BASE_URL_SSL_'))
|
if (!defined('_PS_BASE_URL_SSL_'))
|
||||||
define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
|
define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
|
||||||
|
|
||||||
|
$this->ssl_enable = Configuration::get('PS_SSL_ENABLED');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,7 +213,7 @@ class LinkCore
|
|||||||
*/
|
*/
|
||||||
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null)
|
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null)
|
||||||
{
|
{
|
||||||
$base = (($ssl && Configuration::get('PS_SSL_ENABLED')) ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
|
$base = (($ssl && $this->ssl_enable) ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
|
||||||
|
|
||||||
if (!$id_lang)
|
if (!$id_lang)
|
||||||
$id_lang = Context::getContext()->language->id;
|
$id_lang = Context::getContext()->language->id;
|
||||||
@@ -301,7 +305,7 @@ class LinkCore
|
|||||||
*/
|
*/
|
||||||
public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = false, $id_lang = null)
|
public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = false, $id_lang = null)
|
||||||
{
|
{
|
||||||
$base = (($ssl && Configuration::get('PS_SSL_ENABLED')) ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
|
$base = (($ssl && $this->ssl_enable) ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
|
||||||
|
|
||||||
if (!$id_lang)
|
if (!$id_lang)
|
||||||
$id_lang = Context::getContext()->language->id;
|
$id_lang = Context::getContext()->language->id;
|
||||||
@@ -401,7 +405,7 @@ class LinkCore
|
|||||||
unset($request['controller']);
|
unset($request['controller']);
|
||||||
|
|
||||||
$uri_path = Dispatcher::getInstance()->createUrl($controller, $request);
|
$uri_path = Dispatcher::getInstance()->createUrl($controller, $request);
|
||||||
$url = ($ssl && Configuration::get('PS_SSL_ENABLED')) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true);
|
$url = ($ssl && $this->ssl_enable) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true);
|
||||||
$url .= __PS_BASE_URI__.$this->getLangLink($id_lang).ltrim($uri_path, '/');
|
$url .= __PS_BASE_URI__.$this->getLangLink($id_lang).ltrim($uri_path, '/');
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
|
|||||||
+9
-5
@@ -2370,6 +2370,11 @@ class ProductCore extends ObjectModel
|
|||||||
$id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $with_ecotax, &$specific_price, $use_group_reduction,
|
$id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $with_ecotax, &$specific_price, $use_group_reduction,
|
||||||
$id_customer = 0, $use_customer_price = true, $id_cart = 0)
|
$id_customer = 0, $use_customer_price = true, $id_cart = 0)
|
||||||
{
|
{
|
||||||
|
static $address = null;
|
||||||
|
|
||||||
|
if ($address === null)
|
||||||
|
$address = new Address();
|
||||||
|
|
||||||
if (!$use_customer_price)
|
if (!$use_customer_price)
|
||||||
$id_customer = 0;
|
$id_customer = 0;
|
||||||
|
|
||||||
@@ -2382,6 +2387,9 @@ class ProductCore extends ObjectModel
|
|||||||
'-'.$quantity.'-'.$product_attribute_label.'-'.($use_tax?'1':'0').'-'.$decimals.'-'.($only_reduc?'1':'0').
|
'-'.$quantity.'-'.$product_attribute_label.'-'.($use_tax?'1':'0').'-'.$decimals.'-'.($only_reduc?'1':'0').
|
||||||
'-'.($use_reduc?'1':'0').'-'.$with_ecotax.'-'.$id_customer;
|
'-'.($use_reduc?'1':'0').'-'.$with_ecotax.'-'.$id_customer;
|
||||||
|
|
||||||
|
if (isset(self::$_prices[$cache_id]))
|
||||||
|
return self::$_prices[$cache_id];
|
||||||
|
|
||||||
// reference parameter is filled before any returns
|
// reference parameter is filled before any returns
|
||||||
$specific_price = SpecificPrice::getSpecificPrice(
|
$specific_price = SpecificPrice::getSpecificPrice(
|
||||||
(int)$id_product,
|
(int)$id_product,
|
||||||
@@ -2395,9 +2403,6 @@ class ProductCore extends ObjectModel
|
|||||||
$id_cart
|
$id_cart
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset(self::$_prices[$cache_id]))
|
|
||||||
return self::$_prices[$cache_id];
|
|
||||||
|
|
||||||
// fetch price & attribute price
|
// fetch price & attribute price
|
||||||
$cache_id_2 = $id_product.'-'.(int)$id_product_attribute;
|
$cache_id_2 = $id_product.'-'.(int)$id_product_attribute;
|
||||||
if (!isset(self::$_pricesLevel2[$cache_id_2]))
|
if (!isset(self::$_pricesLevel2[$cache_id_2]))
|
||||||
@@ -2455,7 +2460,6 @@ class ProductCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tax
|
// Tax
|
||||||
$address = new Address();
|
|
||||||
$address->id_country = $id_country;
|
$address->id_country = $id_country;
|
||||||
$address->id_state = $id_state;
|
$address->id_state = $id_state;
|
||||||
$address->postcode = $zipcode;
|
$address->postcode = $zipcode;
|
||||||
@@ -3448,7 +3452,7 @@ class ProductCore extends ObjectModel
|
|||||||
$usetax = Tax::excludeTaxeOption();
|
$usetax = Tax::excludeTaxeOption();
|
||||||
|
|
||||||
$cache_key = $row['id_product'].'-'.$row['id_product_attribute'].'-'.$id_lang.'-'.(int)$usetax;
|
$cache_key = $row['id_product'].'-'.$row['id_product_attribute'].'-'.$id_lang.'-'.(int)$usetax;
|
||||||
if (array_key_exists($cache_key, self::$producPropertiesCache))
|
if (isset(self::$producPropertiesCache[$cache_key]))
|
||||||
return self::$producPropertiesCache[$cache_key];
|
return self::$producPropertiesCache[$cache_key];
|
||||||
|
|
||||||
// Datas
|
// Datas
|
||||||
|
|||||||
@@ -395,7 +395,11 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function isFeatureActive()
|
public static function isFeatureActive()
|
||||||
{
|
{
|
||||||
return Configuration::get('PS_SPECIFIC_PRICE_FEATURE_ACTIVE');
|
static $feature_active = null;
|
||||||
|
|
||||||
|
if ($feature_active === null)
|
||||||
|
$feature_active = Configuration::get('PS_SPECIFIC_PRICE_FEATURE_ACTIVE');
|
||||||
|
return $feature_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function exists($id_product, $id_product_attribute, $id_shop, $id_group, $id_country, $id_currency, $id_customer, $from_quantity, $from, $to, $rule = false)
|
public static function exists($id_product, $id_product_attribute, $id_shop, $id_group, $id_country, $id_currency, $id_customer, $from_quantity, $from, $to, $rule = false)
|
||||||
|
|||||||
+11
-2
@@ -502,6 +502,11 @@ class ToolsCore
|
|||||||
*/
|
*/
|
||||||
public static function convertPrice($price, $currency = null, $to_currency = true, Context $context = null)
|
public static function convertPrice($price, $currency = null, $to_currency = true, Context $context = null)
|
||||||
{
|
{
|
||||||
|
static $default_currency = null;
|
||||||
|
|
||||||
|
if ($default_currency === null)
|
||||||
|
$default_currency = (int)Configuration::get('PS_CURRENCY_DEFAULT');
|
||||||
|
|
||||||
if (!$context)
|
if (!$context)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
if ($currency === null)
|
if ($currency === null)
|
||||||
@@ -512,7 +517,7 @@ class ToolsCore
|
|||||||
$c_id = (is_array($currency) ? $currency['id_currency'] : $currency->id);
|
$c_id = (is_array($currency) ? $currency['id_currency'] : $currency->id);
|
||||||
$c_rate = (is_array($currency) ? $currency['conversion_rate'] : $currency->conversion_rate);
|
$c_rate = (is_array($currency) ? $currency['conversion_rate'] : $currency->conversion_rate);
|
||||||
|
|
||||||
if ($c_id != (int)Configuration::get('PS_CURRENCY_DEFAULT'))
|
if ($c_id != $default_currency)
|
||||||
{
|
{
|
||||||
if ($to_currency)
|
if ($to_currency)
|
||||||
$price *= $c_rate;
|
$price *= $c_rate;
|
||||||
@@ -1139,7 +1144,11 @@ class ToolsCore
|
|||||||
*/
|
*/
|
||||||
public static function ps_round($value, $precision = 0)
|
public static function ps_round($value, $precision = 0)
|
||||||
{
|
{
|
||||||
$method = (int)Configuration::get('PS_PRICE_ROUND_MODE');
|
static $method = null;
|
||||||
|
|
||||||
|
if ($method == null)
|
||||||
|
$method = (int)Configuration::get('PS_PRICE_ROUND_MODE');
|
||||||
|
|
||||||
if ($method == PS_ROUND_UP)
|
if ($method == PS_ROUND_UP)
|
||||||
return Tools::ceilf($value, $precision);
|
return Tools::ceilf($value, $precision);
|
||||||
elseif ($method == PS_ROUND_DOWN)
|
elseif ($method == PS_ROUND_DOWN)
|
||||||
|
|||||||
+5
-1
@@ -163,7 +163,11 @@ class TaxCore extends ObjectModel
|
|||||||
|
|
||||||
public static function excludeTaxeOption()
|
public static function excludeTaxeOption()
|
||||||
{
|
{
|
||||||
return !Configuration::get('PS_TAX');
|
static $ps_tax = null;
|
||||||
|
if ($ps_tax === null)
|
||||||
|
$ps_tax = Configuration::get('PS_TAX');
|
||||||
|
|
||||||
|
return !$ps_tax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user