From 230738441b1275b118d4c284ac3135db836f2a08 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 --- 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 690a568..0b4e16f 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.1.0