From 8765acc0a5675cd20842256e213a14b90ef3f094 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 17 Dec 2019 08:25:28 -0500 Subject: [PATCH] Bug 24254: Add get_visible_items method --- Koha/Biblio.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index b5ffe81642..4d1ac3f460 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -41,6 +41,7 @@ use Koha::Item::Transfer::Limits; use Koha::Items; use Koha::Libraries; use Koha::Subscriptions; +use Koha::Util::SystemPreferences; =head1 NAME @@ -351,6 +352,29 @@ sub items { return Koha::Items->_new_from_dbic( $items_rs ); } +=head3 get_visible_items + +my $items = $biblio->get_visible_items(); + +Returns the related Koha::Items object for this biblio +excluding hidden items + +=cut + +sub get_visible_items { + my ($self) = @_; + + my $rules = get_yaml_pref_hash('OpacHiddenItems'); + my $search_params; + foreach my $field (keys %$rules){ + $search_params->{$field}->{'not in'} = $rules->{$field}; + } + my $items_rs = $self->_result->items; + $items_rs = $items_rs->search( $search_params ) if $items_rs; + + return Koha::Items->_new_from_dbic( $items_rs ); +} + =head3 itemtype my $itemtype = $biblio->itemtype(); -- 2.11.0