1 package Koha
::Filter
::MARC
::EmbedItems
;
3 # Copyright 2019 Theke Solutions
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 Koha::Filter::MARC::EmbedItems - Appends item information on MARC::Record objects.
26 my $biblio = Koha::Biblios->find(
28 { prefetch => [ items, metadata ] }
31 my $opachiddenitems_rules;
33 my $yaml = C4::Context->preference('OpacHiddenItems') . "\n\n";
34 $opachiddenitems_rules = YAML::Load($yaml);
37 my @items = grep { !$_->hidden_in_opac({ rules => $opachiddenitems_rules }) @{$biblio->items};
38 my $record = $biblio->metadata->record;
40 my $processor = Koha::RecordProcessor->new(
42 filters => ('EmbedItems'),
49 $processor->process( $record );
53 Filter to embed items information into MARC::Record objects.
61 use base
qw(Koha::RecordProcessor::Base);
62 our $NAME = 'EmbedItems';
66 Embed items into the MARC::Record object.
74 return unless defined $record and ref($record) eq 'MARC::Record';
76 my $items = $self->{params
}->{options
}->{items
};
77 my $mss = $self->{params
}->{options
}->{mss
}
78 // C4
::Biblio
::GetMarcSubfieldStructure
( '', { unsafe
=> 1 } );
82 foreach my $item ( @
{$items} ) {
83 push @item_fields, $item->as_marc_field( { mss
=> $mss } );
86 $record->append_fields(@item_fields);