From 0fa52d7b656527b272cb9d9a1cbcef3a4857611a Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 4 Sep 2020 12:25:17 +0400 Subject: [PATCH] Bug 25375: Get biblionumber from the correct MARC field MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Nick Clemens Signed-off-by: Nick Clemens Signed-off-by: Joonas Kylmälä Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 0ce7293ad52c9f817859e34d8161a847c58f1707) Signed-off-by: Lucas Gass --- Koha/SearchEngine/Elasticsearch.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index 38dd7321d5..c49aa17b6d 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -30,6 +30,7 @@ use Koha::SearchMarcMaps; use Koha::Caches; use C4::Heading; use C4::AuthoritiesMarc qw( GuessAuthTypeCode ); +use C4::Biblio; use Carp qw( carp croak ); use Clone qw( clone ); @@ -773,7 +774,10 @@ sub marc_records_to_documents { # Check if there is at least one available item if ($self->index eq $BIBLIOS_INDEX) { - my $biblio = Koha::Biblios->find($record->field('001')->data); + my ($tag, $code) = C4::Biblio::GetMarcFromKohaField('biblio.biblionumber'); + my $field = $record->field($tag); + my $biblionumber = $field->is_control_field ? $field->data : $field->subfield($code); + my $biblio = Koha::Biblios->find($biblionumber); my $items = $biblio->items; my $available = 0; while (my $item = $items->next) { -- 2.39.5