Bug 12478: facets - Display description instead of code for locations
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 5 Oct 2015 11:50:52 +0000 (12:50 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 26 Apr 2016 13:00:41 +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 bd53f80..22182ea 100644 (file)
@@ -39,7 +39,9 @@ Koha::SearchEngine::ElasticSearch::Search - search functions for Elasticsearch
 =cut
 
 use base qw(Koha::ElasticSearch);
+use C4::Context;
 use Koha::ItemTypes;
+use Koha::AuthorisedValues;
 use Koha::SearchEngine::QueryBuilder;
 
 use Catmandu::Store::ElasticSearch;
@@ -400,8 +402,11 @@ 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->search;
+    my @locations = Koha::AuthorisedValues->search( { category => 'LOC' } );
+    my $opac = C4::Context->interface eq 'opac' ;
     my %special = (
-        itype => { map { $_->itemtype => $_->description } @itypes },
+        itype    => { map { $_->itemtype         => $_->description } @itypes },
+        location => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @locations },
     );
     my @res;
     $exp_facet //= '';