@@ -, +, @@ > koha-elasticsearch --reset --rebuild kohadev Visual Materials) and check "Hide in OPAC". not appear as facet. itemtype still does appear as a facet. not appear as facet. itemtype still does appear as a facet. --- C4/Search.pm | 14 ++++++++++++++ Koha/SearchEngine/Elasticsearch/Search.pm | 4 ++++ 2 files changed, 18 insertions(+) --- a/C4/Search.pm +++ a/C4/Search.pm @@ -619,6 +619,20 @@ sub GetFacets { $facets = _get_facets_from_records( $rs ); } + if ( C4::Context->interface eq 'opac' ) { + for my $k ( keys %$facets ) { + if ( $k eq 'itype' ) { + my $itemtypes = Koha::ItemTypes->new; + for my $fv ( keys %{ $facets->{$k} } ) { + my $itemtype = $itemtypes->find($fv); + if ( defined $itemtype && $itemtype->hideinopac ) { + delete $facets->{$k}->{$fv}; + } + } + } + } + } + return $facets; } --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ a/Koha/SearchEngine/Elasticsearch/Search.pm @@ -476,6 +476,9 @@ sub _convert_facets { holdingbranch => $library_names, homebranch => $library_names ); + + my @hidden_itemtypes = map { $_->itemtype } ( grep { $opac && $_->hideinopac } @itypes ); + my @facets; $exp_facet //= ''; while ( my ( $type, $data ) = each %$es ) { @@ -495,6 +498,7 @@ sub _convert_facets { next unless length($t); # FIXME Currently we cannot search for an empty faceted field i.e. ln:"" to find records missing languages, though ES does count them correctly my $c = $term->{doc_count}; my $label; + next if $type eq 'itype' && grep { $_ eq $t } @hidden_itemtypes; if ( exists( $special{$type} ) ) { $label = $special{$type}->{$t} // $t; } --