View | Details | Raw Unified | Return to bug 37710
Collapse All | Expand All

(-)a/Koha/Biblio.pm (+34 lines)
Lines 1934-1939 sub generate_marc_host_field { Link Here
1934
    return $link_field;
1934
    return $link_field;
1935
}
1935
}
1936
1936
1937
=head3 unlink_marc_host
1938
1939
  $biblio->unlink_marc_host({ host => $biblio });
1940
  $biblio->unlink_marc_host({ host => $biblionumber });
1941
1942
Remove the link to the parent created by link_marc_host. Expects either the biblio object or biblionumber of the host to link to.
1943
1944
=cut
1945
1946
sub unlink_marc_host {
1947
    my ( $self, $params ) = @_;
1948
    my $host_biblionumber;
1949
    if ( ref( $params->{host} ) eq 'Koha::Biblio' ) {
1950
        $host_biblionumber = $params->{host}->biblionumber;
1951
    } else {
1952
        $host_biblionumber = $params->{host};
1953
    }
1954
1955
    my $record       = $self->metadata->record;
1956
    my $field_number = C4::Context->preference('marcflavour') eq 'MARC21' ? '773' : '461';
1957
    my @fields       = $record->field($field_number);
1958
1959
    foreach my $field (@fields) {
1960
        my $subfield_biblionumber = $field->subfield('0') // q{};
1961
        if ( $host_biblionumber eq $subfield_biblionumber ) {
1962
            $record->delete_field($field);
1963
            last;
1964
        }
1965
    }
1966
1967
    C4::Biblio::ModBiblio( $record, $self->biblionumber );
1968
}
1969
1970
1937
=head3 link_marc_host
1971
=head3 link_marc_host
1938
1972
1939
  $biblio->link_marc_host({ field => $link_field});
1973
  $biblio->link_marc_host({ field => $link_field});
(-)a/Koha/REST/V1/Items.pm (-1 / +1 lines)
Lines 411-416 sub remove_from_bundle { Link Here
411
        unless $bundle_item;
411
        unless $bundle_item;
412
412
413
    return try {
413
    return try {
414
        $bundle_item->biblio->unlink_marc_host( { host => $item->biblio } );
414
        $bundle_item->remove_from_bundle;
415
        $bundle_item->remove_from_bundle;
415
        return $c->render_resource_deleted;
416
        return $c->render_resource_deleted;
416
    } catch {
417
    } catch {
417
- 

Return to bug 37710