From ef3ac7b5b1f3ee67ff82ca581bbb81f35481b9dd Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 19 Nov 2024 14:49:14 +0000 Subject: [PATCH] Bug 14907: Sort item search by cn_sort when sorting by callnumber This patch simply intercepts a call to sort by callnumber and changes it to cn_sort To test: 1 - Add three items: barcode TEST1 callnumnber D1015.B4 1965 barcode TEST2 callnumnber D102.D3 1930 barcode TEST3 callnumnber D101.2.A8 1951 2 - Go to item search 3 - barcode is 'TEST%' 4 - Sort the results by callnumber 5 - order is TEST3,TEST1,TEST2 (or reversed depending on sort direction) 6 - Apply patch, restart_all 7 - sort again 8 - order is TEST3,TEST2,TEST1 (or reversed depending on sort direction) Signed-off-by: Gretchen Maxeiner Signed-off-by: Heather Hernandez --- C4/Items.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/C4/Items.pm b/C4/Items.pm index 920b6c77f3..82882dccf8 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1238,6 +1238,7 @@ sub SearchItems { } else { my $sortby = (0 < grep {$params->{sortby} eq $_} @columns) ? $params->{sortby} : 'itemnumber'; + $sortby = 'cn_sort' if $sortby eq 'itemcallnumber'; my $sortorder = (uc($params->{sortorder}) eq 'ASC') ? 'ASC' : 'DESC'; $query .= qq{ ORDER BY $sortby $sortorder }; } -- 2.39.5