From ae2d0a9688d9897d5a10f6271d05a724a877f36c Mon Sep 17 00:00:00 2001 From: Arnaud Hours Date: Thu, 30 Oct 2025 15:02:40 +0100 Subject: [PATCH 1/2] fix(order): fix unoptimized count in the order listing --- Controllers/Backend/LengowImport.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Controllers/Backend/LengowImport.php b/Controllers/Backend/LengowImport.php index a46db03..750f21c 100755 --- a/Controllers/Backend/LengowImport.php +++ b/Controllers/Backend/LengowImport.php @@ -140,8 +140,17 @@ public function getListAction() if ($order['property'] && $order['direction']) { $builder->orderBy($order['property'], $order['direction']); } - $builder->distinct()->addOrderBy('orderLengow.orderDate', 'DESC'); - $totalOrders = count($builder->getQuery()->getArrayResult()); + $builder->addOrderBy('orderLengow.orderDate', 'DESC'); +// $builder->distinct(); + + $countBuilder = clone $builder; + $countBuilder->resetDQLPart('select') + ->resetDQLPart('orderBy') + ->setFirstResult(null) + ->setMaxResults(null) + ->select('COUNT(DISTINCT orderLengow.id)'); + $totalOrders = (int) $countBuilder->getQuery()->getSingleScalarResult(); + $builder->setFirstResult($start)->setMaxResults($limit); $results = $builder->getQuery()->getArrayResult(); $orderErrors = $this->getOrderErrors(); From 9eb8807de4154b3dc18d568830d80645d0d81905 Mon Sep 17 00:00:00 2001 From: Arnaud Hours Date: Thu, 30 Oct 2025 15:34:43 +0100 Subject: [PATCH 2/2] fix(order): fix unoptimized count in the order listing --- Controllers/Backend/LengowImport.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Controllers/Backend/LengowImport.php b/Controllers/Backend/LengowImport.php index 750f21c..61fd549 100755 --- a/Controllers/Backend/LengowImport.php +++ b/Controllers/Backend/LengowImport.php @@ -103,10 +103,10 @@ public function getListAction() $builder = $em->createQueryBuilder(); $builder->select($select) ->from('Shopware\CustomModels\Lengow\Order', 'orderLengow') - ->leftJoin('Shopware\Models\Shop\Shop', 'shops', 'WITH', 'orderLengow.shopId = shops.id') - ->leftJoin('orderLengow.order', 's_order') - ->leftJoin('Shopware\Models\Order\Status', 's_core_states', 'WITH', 's_order.status = s_core_states') - ->leftJoin( + ->innerJoin('Shopware\Models\Shop\Shop', 'shops', 'WITH', 'orderLengow.shopId = shops.id') + ->innerJoin('orderLengow.order', 's_order') + ->innerJoin('Shopware\Models\Order\Status', 's_core_states', 'WITH', 's_order.status = s_core_states') + ->innerJoin( 'Shopware\Models\Country\Country', 's_core_countries', 'WITH', @@ -141,7 +141,7 @@ public function getListAction() $builder->orderBy($order['property'], $order['direction']); } $builder->addOrderBy('orderLengow.orderDate', 'DESC'); -// $builder->distinct(); + $builder->distinct(); $countBuilder = clone $builder; $countBuilder->resetDQLPart('select')