From aca146aeba34a7f1acc563a53296176a41ca8e49 Mon Sep 17 00:00:00 2001
From: Arthur Suzuki <arthur.suzuki@biblibre.com>
Date: Fri, 11 Oct 2019 23:42:25 +0200
Subject: [PATCH] bug23800 : fix regression in batch item modification tool

Test plan :
1/ scan several items in the Tools / Batch Item Modification
2/ click continue
3/ check that items were not displayed in the order they appeared in
4/ apply patch
5/ repeat step 1 and 2
6/ verify that items now appear in the order they were scanned
---
 tools/batchMod.pl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/batchMod.pl b/tools/batchMod.pl
index 2e6473784c..b4a98c6b4a 100755
--- a/tools/batchMod.pl
+++ b/tools/batchMod.pl
@@ -282,7 +282,9 @@ if ($op eq "show"){
             my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
             @barcodelist = uniq @barcodelist;
 
-            my $existing_items = Koha::Items->search({ barcode => \@barcodelist });
+            my $order = "field(" . join(",","barcode",@barcodelist) . ")";
+            my $existing_items = Koha::Items->search({ barcode => \@barcodelist },
+                                                     { order_by => \[$order] } );
             @itemnumbers = $existing_items->get_column('itemnumber');
             my @barcodes = $existing_items->get_column('barcode');
             my %exists = map {lc($_)=>1} @barcodes;
-- 
2.20.1