From e8950b6b00fe52a8bfed12bc3b6fbf193343e853 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 5 Oct 2015 12:17:09 +0100 Subject: [PATCH] Bug 12478: Use the new Koha::ItemTypes to retrieve itypes descriptions Signed-off-by: Nick Clemens Signed-off-by: Jesse Weaver Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall Signed-off-by: Brendan Gallagher --- Koha/SearchEngine/Elasticsearch/Search.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm index 4f5a1376ab..bd53f80ec4 100644 --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ b/Koha/SearchEngine/Elasticsearch/Search.pm @@ -399,8 +399,10 @@ sub _convert_facets { # We also have some special cases, e.g. itypes that need to show the # value rather than the code. - my $itypes = Koha::ItemTypes->new(); - my %special = ( itype => sub { $itypes->get_description_for_code(@_) }, ); + my @itypes = Koha::ItemTypes->search; + my %special = ( + itype => { map { $_->itemtype => $_->description } @itypes }, + ); my @res; $exp_facet //= ''; while ( ( $type, $data ) = each %$es ) { @@ -421,7 +423,7 @@ sub _convert_facets { my $t = $term->{term}; my $c = $term->{count}; if ( exists( $special{$type} ) ) { - $label = $special{$type}->($t); + $label = $special{$type}->{$t} // $t; } else { $label = $t; -- 2.39.5