Bug 12478: Use the new Koha::ItemTypes to retrieve itypes descriptions
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 5 Oct 2015 11:17:09 +0000 (12:17 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 26 Apr 2016 13:00:32 +0000 (10:00 -0300)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Koha/SearchEngine/Elasticsearch/Search.pm

index 4f5a137..bd53f80 100644 (file)
@@ -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;