From 943dd9c1358e4b585b472cc82da7db55c88a9d3c Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 4 Mar 2024 16:01:00 +0000 Subject: [PATCH] Bug 35484: Make secondary sort use biblio.title To test: 1. In k-t-d, set all item itemcallnumbers to the same thing, ie: 'abcdefg'; 2. Touch all items to update the cn_sort values 3. Turn on OPACShelfBrowser and view a record detail page on the OPAC. 4. Browse the shelf and see that all items are organized by itemnumber. 5. APPLY PATCH and restart_services 6. Try again, now the secondary sort should be using biblio.title, not itemnumber. --- C4/ShelfBrowser.pm | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/C4/ShelfBrowser.pm b/C4/ShelfBrowser.pm index 5c9159d002..6f7ce17be0 100644 --- a/C4/ShelfBrowser.pm +++ b/C4/ShelfBrowser.pm @@ -139,41 +139,45 @@ sub GetNearbyItems { # Build the query for previous and next items my $prev_query =' - SELECT itemnumber, biblionumber, cn_sort, itemcallnumber + SELECT items.itemnumber, items.biblionumber, items.cn_sort, items.itemcallnumber FROM items + LEFT JOIN biblio + ON ( items.biblionumber = biblio.biblionumber ) WHERE - ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) '; + ((items.cn_sort = ? AND items.itemnumber < ?) OR items.cn_sort < ?) '; my $next_query =' - SELECT itemnumber, biblionumber, cn_sort, itemcallnumber + SELECT items.itemnumber, items.biblionumber, items.cn_sort, items.itemcallnumber FROM items + LEFT JOIN biblio + ON ( items.biblionumber = biblio.biblionumber ) WHERE - ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) '; + ((items.cn_sort = ? AND items.itemnumber >= ?) OR items.cn_sort > ?) '; my @params; my $query_cond; push @params, ($start_cn_sort, $itemnumber, $start_cn_sort); if ($start_homebranch) { - $query_cond .= 'AND homebranch = ? '; + $query_cond .= 'AND items.homebranch = ? '; push @params, $start_homebranch->{code}; } if ($start_location) { - $query_cond .= 'AND location = ? '; + $query_cond .= 'AND items.location = ? '; push @params, $start_location->{code}; } if ($start_ccode) { - $query_cond .= 'AND ccode = ? '; + $query_cond .= 'AND items.ccode = ? '; push @params, $start_ccode->{code}; } my @prev_items = @{ $dbh->selectall_arrayref( - $prev_query . $query_cond . ' ORDER BY cn_sort DESC, itemnumber DESC LIMIT ?', + $prev_query . $query_cond . ' ORDER BY items.cn_sort DESC, biblio.title DESC LIMIT ?', { Slice => {} }, ( @params, $gap ) ) }; my @next_items = @{ $dbh->selectall_arrayref( - $next_query . $query_cond . ' ORDER BY cn_sort, itemnumber LIMIT ?', + $next_query . $query_cond . ' ORDER BY items.cn_sort, itemnumber LIMIT ?', { Slice => {} }, ( @params, $gap + 1 ) ) -- 2.30.2