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

(-)a/Koha/Biblio.pm (+32 lines)
Lines 2095-2100 sub link_marc_bundled_item { Link Here
2095
    return $self;
2095
    return $self;
2096
}
2096
}
2097
2097
2098
=head3 unlink_marc_bundled_item
2099
2100
  $biblio->unlink_marc_bundled_item({ bundled_item => $item });
2101
  $biblio->unlink_marc_bundled_item({ bundled_item => $itemnumber });
2102
2103
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.
2104
2105
=cut
2106
2107
sub unlink_marc_bundled_item {
2108
    my ( $self, $params ) = @_;
2109
    my $bundled_item_itemnumber;
2110
    if ( ref( $params->{bundled_item} ) eq 'Koha::Item' ) {
2111
        $bundled_item_itemnumber = $params->{bundled_item}->itemnumber;
2112
    } else {
2113
        $bundled_item_itemnumber = $params->{bundled_item};
2114
    }
2115
2116
    my $record       = $self->metadata->record;
2117
    my $field_number = C4::Context->preference('marcflavour') eq 'MARC21' ? '774' : '462';
2118
    my @fields       = $record->field($field_number);
2119
2120
    foreach my $field (@fields) {
2121
        my $subfield_itemnumber = $field->subfield('9') // q{};
2122
        if ( $bundled_item_itemnumber eq $subfield_itemnumber ) {
2123
            $record->delete_field($field);
2124
        }
2125
    }
2126
2127
    C4::Biblio::ModBiblio( $record, $self->biblionumber );
2128
}
2129
2098
=head3 recalls
2130
=head3 recalls
2099
2131
2100
    my $recalls = $biblio->recalls;
2132
    my $recalls = $biblio->recalls;
(-)a/Koha/REST/V1/Items.pm (-1 / +2 lines)
Lines 412-417 sub remove_from_bundle { Link Here
412
        unless $bundle_item;
412
        unless $bundle_item;
413
413
414
    return try {
414
    return try {
415
        $bundle_item->biblio->unlink_marc_host({ host => $item->biblio });
416
        $item->biblio->unlink_marc_bundled_item( { bundled_item => $bundle_item } );
415
        $bundle_item->remove_from_bundle;
417
        $bundle_item->remove_from_bundle;
416
        return $c->render_resource_deleted;
418
        return $c->render_resource_deleted;
417
    } catch {
419
    } catch {
418
- 

Return to bug 38093