From b15d3a21c936989a39f87b032f5466a33fd18383 Mon Sep 17 00:00:00 2001 From: mattgoud Date: Tue, 2 Jun 2026 14:32:12 +0200 Subject: [PATCH] Fix SQL queries using NOW() with MySQL timezone instead of shop timezone Replace NOW() in raw SQL queries with PHP's date() so that the shop's configured timezone is always used instead of the MySQL server timezone (UTC). Fixes PrestaShop/PrestaShop#30828 Co-Authored-By: Claude Sonnet 4.6 --- statsbestproducts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statsbestproducts.php b/statsbestproducts.php index 42cb550..d7872f0 100644 --- a/statsbestproducts.php +++ b/statsbestproducts.php @@ -152,7 +152,7 @@ public function getData() ROUND(AVG(od.unit_price_tax_excl / o.conversion_rate), 2) as avgPriceSold, IFNULL(stock.quantity, 0) as quantity, IFNULL(SUM(od.product_quantity), 0) AS totalQuantitySold, - ROUND(IFNULL(IFNULL(SUM(od.product_quantity), 0) / (1 + LEAST(TO_DAYS(' . $array_date_between[1] . '), TO_DAYS(NOW())) - GREATEST(TO_DAYS(' . $array_date_between[0] . '), TO_DAYS(product_shop.date_add))), 0), 2) as averageQuantitySold, + ROUND(IFNULL(IFNULL(SUM(od.product_quantity), 0) / (1 + LEAST(TO_DAYS(' . $array_date_between[1] . '), TO_DAYS(\'' . date('Y-m-d') . '\')) - GREATEST(TO_DAYS(' . $array_date_between[0] . '), TO_DAYS(product_shop.date_add))), 0), 2) as averageQuantitySold, ROUND(IFNULL(SUM((od.unit_price_tax_excl * od.product_quantity) / o.conversion_rate), 0), 2) AS totalPriceSold, ( SELECT IFNULL(SUM(pv.counter), 0)