From 78e99be511778e4d29d8553636d95d7b22311fe5 Mon Sep 17 00:00:00 2001 From: josemariagomezroncero Date: Tue, 17 Jun 2025 20:16:00 +0200 Subject: [PATCH] Update MySQL.php Improves query speed for MySQL 5.7, MariaDB 10.3+ --- src/Adapter/MySQL.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Adapter/MySQL.php b/src/Adapter/MySQL.php index 870d2f32c..b3e953343 100644 --- a/src/Adapter/MySQL.php +++ b/src/Adapter/MySQL.php @@ -248,7 +248,7 @@ protected function getFieldMapping() 'out_of_stock' => [ 'tableName' => 'stock_available', 'tableAlias' => 'sa', - 'joinCondition' => '(p.id_product = sa.id_product AND IFNULL(pac.id_product_attribute, 0) = sa.id_product_attribute' . + 'joinCondition' => '(p.id_product = sa.id_product AND (pac.id_product_attribute = sa.id_product_attribute OR (pac.id_product_attribute IS NULL AND sa.id_product_attribute = 0)) ' . $stockCondition . ')', 'joinType' => self::LEFT_JOIN, 'dependencyField' => 'id_attribute', @@ -256,7 +256,7 @@ protected function getFieldMapping() 'quantity' => [ 'tableName' => 'stock_available', 'tableAlias' => 'sa', - 'joinCondition' => '(p.id_product = sa.id_product AND IFNULL(pac.id_product_attribute, 0) = sa.id_product_attribute' . + 'joinCondition' => '(p.id_product = sa.id_product AND (pac.id_product_attribute = sa.id_product_attribute OR (pac.id_product_attribute IS NULL AND sa.id_product_attribute = 0)) ' . $stockCondition . ')', 'joinType' => self::LEFT_JOIN, 'dependencyField' => 'id_attribute',