From 21df96eeac61201b16b4dddd59809cfe1b4d5dd3 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 --- 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 aa9da8b..690a568 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.1.0