From f7556cca4f29a094246cda05bc77aaba5a795875 Mon Sep 17 00:00:00 2001 From: PululuK Date: Wed, 24 Apr 2024 11:36:52 +0200 Subject: [PATCH] Improve `Product::priceCalculation` performances --- classes/Product.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/Product.php b/classes/Product.php index 28bfffb83c181..8c569d452c3a9 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3562,6 +3562,10 @@ public static function priceCalculation( '-' . (int) $with_ecotax . '-' . (int) $id_customer . '-' . (int) $use_group_reduction . '-' . (int) $id_cart . '-' . (int) $real_quantity . '-' . ($only_reduc ? '1' : '0') . '-' . ($use_reduc ? '1' : '0') . '-' . ($use_tax ? '1' : '0') . '-' . (int) $decimals; + if (isset(self::$_prices[$cache_id])) { + return self::$_prices[$cache_id]; + } + // reference parameter is filled before any returns $specific_price = SpecificPrice::getSpecificPrice( (int) $id_product, @@ -3576,10 +3580,6 @@ public static function priceCalculation( $real_quantity ); - if (isset(self::$_prices[$cache_id])) { - return self::$_prices[$cache_id]; - } - // fetch price & attribute price $cache_id_2 = $id_product . '-' . $id_shop; // We need to check the cache for this price AND attribute, if absent the whole product cache needs update