Bugzilla – Attachment 164978 Details for
Bug 14007
Values listed in OpacHiddenItems should not appear in OPAC facets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14007: Hide hidden itemtypes in opac facets.
Bug-14007-Hide-hidden-itemtypes-in-opac-facets.patch (text/plain), 3.02 KB, created by
Andreas Jonsson
on 2024-04-17 08:22:02 UTC
(
hide
)
Description:
Bug 14007: Hide hidden itemtypes in opac facets.
Filename:
MIME Type:
Creator:
Andreas Jonsson
Created:
2024-04-17 08:22:02 UTC
Size:
3.02 KB
patch
obsolete
>From 978e38dd4ef063067f2398cd5991080c968b6ee1 Mon Sep 17 00:00:00 2001 >From: Andreas Jonsson <andreas.jonsson@kreablo.se> >Date: Wed, 17 Apr 2024 08:10:46 +0000 >Subject: [PATCH] Bug 14007: Hide hidden itemtypes in opac facets. > >Test plan: > >* Start koha-testing-docker with elasticsearch or opensearch (e.g., ku-es7) >* Make sure there is a built index for Elastic/OpenSearch: > > > koha-elasticsearch --reset --rebuild kohadev > >* Search for "book" in opac and note the facet values for itemtype >* Change systempreference SearchEngine to ElasticSearch >* Search for "book" in opac and note the facet values for itemtype >* Go to the adminstration view of one of the itemtypes (for instance > Visual Materials) and check "Hide in OPAC". >* Search for "book" in opac and make sure the hidden itemtype do > not appear as facet. >* Search for "book" in staff interface and make sure the hidden > itemtype still does appear as a facet. >* Change back the systemprefence to Zebra >* Search for "book" in opac and make sure the hidden itemtype do > not appear as facet. >* Search for "book" in staff interface and make sure the hidden > itemtype still does appear as a facet. >--- > C4/Search.pm | 14 ++++++++++++++ > Koha/SearchEngine/Elasticsearch/Search.pm | 4 ++++ > 2 files changed, 18 insertions(+) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 248856e42b..4ce25412d4 100644 >--- a/C4/Search.pm >+++ b/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; > } > >diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm >index 933b52f79d..1b263560cd 100644 >--- a/Koha/SearchEngine/Elasticsearch/Search.pm >+++ b/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; > } >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14007
:
79233
|
164978
|
166030
|
166066
|
173243
|
173309
|
173365