Lines 1999-2004
sub link_marc_host {
Link Here
|
1999 |
return $self; |
1999 |
return $self; |
2000 |
} |
2000 |
} |
2001 |
|
2001 |
|
|
|
2002 |
=head3 link_marc_bundled_item |
2003 |
|
2004 |
$biblio->link_marc_bundled_item({ bundled_item => $item }); |
2005 |
$biblio->link_marc_bundled_item({ bundled_item => $itemnumber }); |
2006 |
|
2007 |
Links a parent MARC record to the child. Expects either the biblio object or biblionumber of the host to link to. |
2008 |
|
2009 |
=cut |
2010 |
|
2011 |
sub link_marc_bundled_item { |
2012 |
my ( $self, $params ) = @_; |
2013 |
|
2014 |
my $host_link_field; |
2015 |
my $bundled_item; |
2016 |
if ( ref( $params->{bundled_item} ) eq 'Koha::Item' ) { |
2017 |
$bundled_item = $params->{bundled_item}; |
2018 |
} else { |
2019 |
my $bundled_item = Koha::Items->find( $params->{host} ); |
2020 |
} |
2021 |
|
2022 |
my $record = $self->metadata->record; |
2023 |
my $tag = C4::Context->preference('marcflavour') eq 'UNIMARC' ? '462' : '774'; |
2024 |
# Remove fields that references the same itemnumber |
2025 |
# to avoid duplicates |
2026 |
my @fields = $record->field($tag); |
2027 |
my @duplicate_fields = grep { $_->subfield('9') eq $bundled_item->itemnumber; } @fields; |
2028 |
$record->delete_fields(@duplicate_fields); |
2029 |
my $field = MARC::Field->new( |
2030 |
$tag, '', '', |
2031 |
't' => $bundled_item->biblio->title, |
2032 |
'0' => $bundled_item->biblionumber, |
2033 |
'9' => $bundled_item->itemnumber |
2034 |
); |
2035 |
$record->insert_fields_ordered($field); |
2036 |
|
2037 |
C4::Biblio::ModBiblio( $record, $self->biblionumber ); |
2038 |
|
2039 |
return $self; |
2040 |
} |
2041 |
|
2002 |
=head3 recalls |
2042 |
=head3 recalls |
2003 |
|
2043 |
|
2004 |
my $recalls = $biblio->recalls; |
2044 |
my $recalls = $biblio->recalls; |