Lines 2055-2060
sub link_marc_host {
Link Here
|
2055 |
return $self; |
2055 |
return $self; |
2056 |
} |
2056 |
} |
2057 |
|
2057 |
|
|
|
2058 |
=head3 link_marc_bundled_item |
2059 |
|
2060 |
$biblio->link_marc_bundled_item({ bundled_item => $item }); |
2061 |
$biblio->link_marc_bundled_item({ bundled_item => $itemnumber }); |
2062 |
|
2063 |
Links a parent MARC record to the child. Expects either the biblio object or biblionumber of the host to link to. |
2064 |
|
2065 |
=cut |
2066 |
|
2067 |
sub link_marc_bundled_item { |
2068 |
my ( $self, $params ) = @_; |
2069 |
|
2070 |
my $host_link_field; |
2071 |
my $bundled_item; |
2072 |
if ( ref( $params->{bundled_item} ) eq 'Koha::Item' ) { |
2073 |
$bundled_item = $params->{bundled_item}; |
2074 |
} else { |
2075 |
my $bundled_item = Koha::Items->find( $params->{host} ); |
2076 |
} |
2077 |
|
2078 |
my $record = $self->metadata->record; |
2079 |
my $tag = C4::Context->preference('marcflavour') eq 'UNIMARC' ? '462' : '774'; |
2080 |
# Remove fields that references the same itemnumber |
2081 |
# to avoid duplicates |
2082 |
my @fields = $record->field($tag); |
2083 |
my @duplicate_fields = grep { $_->subfield('9') eq $bundled_item->itemnumber; } @fields; |
2084 |
$record->delete_fields(@duplicate_fields); |
2085 |
my $field = MARC::Field->new( |
2086 |
$tag, '', '', |
2087 |
't' => $bundled_item->biblio->title, |
2088 |
'0' => $bundled_item->biblionumber, |
2089 |
'9' => $bundled_item->itemnumber |
2090 |
); |
2091 |
$record->insert_fields_ordered($field); |
2092 |
|
2093 |
C4::Biblio::ModBiblio( $record, $self->biblionumber ); |
2094 |
|
2095 |
return $self; |
2096 |
} |
2097 |
|
2058 |
=head3 recalls |
2098 |
=head3 recalls |
2059 |
|
2099 |
|
2060 |
my $recalls = $biblio->recalls; |
2100 |
my $recalls = $biblio->recalls; |