[Koha-bugs] [Bug 24254] Add Koha::Biblio get_visible_items method

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Dec 2 16:27:53 CET 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24254

--- Comment #4 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
Hi, Nick. I like your approach but have two suggestions:

1. Allow to optionally get passed the rules. This way if the caller is (say)
the opac-search.pl script, we could read the rules once and reuse them.

2. Add this method to Koha::Items, renamed as ->filter_by_visible_in_opac or
similar in the way we've been adding lately.

The method would basically do the same:

sub filter_by_visible_in_opac {
    my ($self, $params) = @_;

    my $rules = (exists $params->{rules})
                ? $params->{rules}
                : get_yaml_pref_hash('OpacHiddenItems');

    my $search_params;
    foreach my $field (keys %$rules){
        $search_params->{$field}->{'not in'} = $rules->{$field};
    }
    return $self->search( $search_params );
}


Then when you use it, you can chain the calls:

    my $visible_items = $biblio->items->filter_by_visible_in_opac;

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list