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

(-)a/Koha/Biblio.pm (+32 lines)
Lines 2039-2044 sub link_marc_bundled_item { Link Here
2039
    return $self;
2039
    return $self;
2040
}
2040
}
2041
2041
2042
=head3 unlink_marc_bundled_item
2043
2044
  $biblio->unlink_marc_bundled_item({ bundled_item => $item });
2045
  $biblio->unlink_marc_bundled_item({ bundled_item => $itemnumber });
2046
2047
Remove the link to the child created by link_marc_bundled_item. Expects either the item object or itemnumber of the host to link to.
2048
2049
=cut
2050
2051
sub unlink_marc_bundled_item {
2052
    my ( $self, $params ) = @_;
2053
    my $bundled_item_itemnumber;
2054
    if ( ref( $params->{bundled_item} ) eq 'Koha::Item' ) {
2055
        $bundled_item_itemnumber = $params->{bundled_item}->itemnumber;
2056
    } else {
2057
        $bundled_item_itemnumber = $params->{bundled_item};
2058
    }
2059
2060
    my $record       = $self->metadata->record;
2061
    my $field_number = C4::Context->preference('marcflavour') eq 'MARC21' ? '774' : '462';
2062
    my @fields       = $record->field($field_number);
2063
2064
    foreach my $field (@fields) {
2065
        my $subfield_itemnumber = $field->subfield('9') // q{};
2066
        if ( $bundled_item_itemnumber eq $subfield_itemnumber ) {
2067
            $record->delete_field($field);
2068
        }
2069
    }
2070
2071
    C4::Biblio::ModBiblio( $record, $self->biblionumber );
2072
}
2073
2042
=head3 recalls
2074
=head3 recalls
2043
2075
2044
    my $recalls = $biblio->recalls;
2076
    my $recalls = $biblio->recalls;
(-)a/Koha/REST/V1/Items.pm (-1 / +1 lines)
Lines 413-418 sub remove_from_bundle { Link Here
413
413
414
    return try {
414
    return try {
415
        $bundle_item->biblio->unlink_marc_host({ host => $item->biblio });
415
        $bundle_item->biblio->unlink_marc_host({ host => $item->biblio });
416
        $item->biblio->unlink_marc_bundled_item( { bundled_item => $bundle_item } );
416
        $bundle_item->remove_from_bundle;
417
        $bundle_item->remove_from_bundle;
417
        return $c->render_resource_deleted;
418
        return $c->render_resource_deleted;
418
    } catch {
419
    } catch {
419
- 

Return to bug 38093