From 7a9d8d6b29c3ab215a0e5493752bfa282d9fff8a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 5 Oct 2015 12:50:52 +0100 Subject: [PATCH] Bug 12478: facets - Display description instead of code for locations 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm index bd53f80ec4..22182ea884 100644 --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ b/Koha/SearchEngine/Elasticsearch/Search.pm @@ -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 //= ''; -- 2.39.5