]> git.koha-community.org Git - koha.git/commit
Bug 23793: Add an EmbedItems RecordProcessor filter for MARC::Record objects
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 10 Oct 2019 16:17:18 +0000 (13:17 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 23 Oct 2019 16:33:07 +0000 (17:33 +0100)
commit6189f25dfae19f99800168db7be996e1239efae3
tree6df1d1e4208c1d3ad67d52d0088457c812331c1b
parent2b149c3d7aa7e2f59fcee6d8778f8e0c685cc406
Bug 23793: Add an EmbedItems RecordProcessor filter for MARC::Record objects

This patch introduces a RecordProcessor filter for MARC::Record objects
that embeds MARC::Field's for each item that is passed to the processor.

Target usage:

my $biblio = Koha::Biblios->find(
    $biblio_id,
    { prefetch => [ items, metadata ] }
);

my $opachiddenitems_rules;
eval {
    my $yaml = C4::Context->preference('OpacHiddenItems') . "\n\n";
    $opachiddenitems_rules = YAML::Load($yaml);
};

my @items  = grep { !$_->hidden_in_opac({ rules => $opachiddenitems_rules }) @{$biblio->items->as_list};
my $record = $biblio->metadata->record;

my $processor = Koha::RecordProcessor->new(
    {
        filters => ('EmbedItems'),
        options => {
            items        => \@items
        }
    }
);

$processor->process( $record );

Signed-off-by: Ere Maijala <ere.maijala@helsinki.fi>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/Filter/MARC/EmbedItems.pm [new file with mode: 0644]