From f00dec88819777b984ecae780c9dea74ff4618b7 Mon Sep 17 00:00:00 2001 From: Tadas Labutis Date: Fri, 22 May 2026 12:13:48 +0300 Subject: [PATCH] Fix Shipment list sorting on joined-table columns Sorts on Tracking number, Receiver, Address, and City fell back to the main shipment table and produced no meaningful ordering. Added order_key entries pointing at the correct join aliases so PS uses the right columns in ORDER BY. filter_key is intentionally left unset so HAVING filters keep targeting the SELECT aliases. Also set default sort to id_dpd_shipment DESC so the latest shipments appear first. --- CHANGELOG.md | 6 +++++- .../admin/AdminDPDBalticsShipmentController.php | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2a49027..7ad3d7ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -185,4 +185,8 @@ ## [3.3.0] - Added PrestaShop 9 compatibility - Fixed issue with price rule "All" -- Fixed other minor issues \ No newline at end of file +- Fixed other minor issues + +## [3.3.1] +- Fixed sorting on Shipment list columns from joined tables (Tracking number, Receiver, Address, City) +- Changed default sort on Shipment list to show latest shipments first \ No newline at end of file diff --git a/controllers/admin/AdminDPDBalticsShipmentController.php b/controllers/admin/AdminDPDBalticsShipmentController.php index 1aafef8b..bd75499e 100644 --- a/controllers/admin/AdminDPDBalticsShipmentController.php +++ b/controllers/admin/AdminDPDBalticsShipmentController.php @@ -49,12 +49,15 @@ public function initToolbar() private function initList() { $this->list_no_link = true; + $this->_defaultOrderBy = 'id_dpd_shipment'; + $this->_defaultOrderWay = 'DESC'; $this->fields_list = [ 'tracking_number' => [ 'title' => $this->module->l('Tracking number'), 'type' => 'text', - 'havingFilter' => true + 'havingFilter' => true, + 'order_key' => 'oc!tracking_number', ], 'date_print' => [ 'title' => $this->module->l('Printing date'), @@ -69,17 +72,20 @@ private function initList() 'receiver_name' => [ 'title' => $this->module->l('Receiver'), 'type' => 'text', - 'havingFilter' => true + 'havingFilter' => true, + 'order_key' => 'c!lastname', ], 'address1' => [ 'title' => $this->module->l('Address'), 'type' => 'text', - 'havingFilter' => true + 'havingFilter' => true, + 'order_key' => 'addr!address1', ], 'city' => [ 'title' => $this->module->l('City'), 'type' => 'text', - 'havingFilter' => true + 'havingFilter' => true, + 'order_key' => 'addr!city', ], 'reference1' => [ 'title' => $this->module->l('Cust Ref 1'),