Bugzilla – Attachment 172396 Details for
Bug 38093
Bundles: Add MARC link options should also add a link in 462
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38093: Bundles: Add MARC link options should also add a link in 462
Bug-38093-Bundles-Add-MARC-link-options-should-als.patch (text/plain), 3.51 KB, created by
Baptiste Wojtkowski (bwoj)
on 2024-10-04 13:06:07 UTC
(
hide
)
Description:
Bug 38093: Bundles: Add MARC link options should also add a link in 462
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2024-10-04 13:06:07 UTC
Size:
3.51 KB
patch
obsolete
>From 48a9be786b746fd3eddfdc313f67e79d29cdc22a Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <bski@laposte.net> >Date: Fri, 4 Oct 2024 11:59:31 +0200 >Subject: [PATCH] Bug 38093: Bundles: Add MARC link options should also add a > link in 462 > >Bundle implementation in Bug 37996 does not implement marc representation of the relation between bundles and items they contain. > >Bug 29560 creates a link (773 in MARC21, 461 in UNIMARC) from the item in the bundle to the bundle itself. > >We also should also add a MARC link from the bundle to the item contained in the dedicated field (774 in MARC21, 462 in UNIMARC). > >TEST PLAN: >1 - Apply patches >2 - Create a bundle item (cf after for more info on this step if you are > unfamiliar with bundles) >3 - Click on "manage bundle", fill with an existing barcode, click on > Add marc link >4 - Click on MARC -> tab 7 (on marc21) and tab 4 on unimarc -> there > should be a link in field 733 (marc21) or 462 (unimarc) >5 - Go back to the bundle and remove the item from the bundle. >6 - Click again on MARC -> precedent fields should now be empty > >Create a bundle : >1 - Create a new biblio/Edit an existing one, edit the field 000, the field >7 must be set to c-Collection. >2 - Go on the biblio and create a new item attached to the biblio >3 - You should see an icon "Manage bundle" on the item created >--- > Koha/Biblio.pm | 40 ++++++++++++++++++++++++++++++++++++++++ > Koha/REST/V1/Items.pm | 1 + > 2 files changed, 41 insertions(+) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index ceeac0f5..c2c011fe 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -1999,6 +1999,46 @@ sub link_marc_host { > return $self; > } > >+=head3 link_marc_bundled_item >+ >+ $biblio->link_marc_bundled_item({ bundled_item => $item }); >+ $biblio->link_marc_bundled_item({ bundled_item => $itemnumber }); >+ >+Links a parent MARC record to the child. Expects either the biblio object or biblionumber of the host to link to. >+ >+=cut >+ >+sub link_marc_bundled_item { >+ my ( $self, $params ) = @_; >+ >+ my $host_link_field; >+ my $bundled_item; >+ if ( ref( $params->{bundled_item} ) eq 'Koha::Item' ) { >+ $bundled_item = $params->{bundled_item}; >+ } else { >+ my $bundled_item = Koha::Items->find( $params->{host} ); >+ } >+ >+ my $record = $self->metadata->record; >+ my $tag = C4::Context->preference('marcflavour') eq 'UNIMARC' ? '462' : '774'; >+ # Remove fields that references the same itemnumber >+ # to avoid duplicates >+ my @fields = $record->field($tag); >+ my @duplicate_fields = grep { $_->subfield('9') eq $bundled_item->itemnumber; } @fields; >+ $record->delete_fields(@duplicate_fields); >+ my $field = MARC::Field->new( >+ $tag, '', '', >+ 't' => $bundled_item->biblio->title, >+ '0' => $bundled_item->biblionumber, >+ '9' => $bundled_item->itemnumber >+ ); >+ $record->insert_fields_ordered($field); >+ >+ C4::Biblio::ModBiblio( $record, $self->biblionumber ); >+ >+ return $self; >+} >+ > =head3 recalls > > my $recalls = $biblio->recalls; >diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm >index cfa60e3b..96978370 100644 >--- a/Koha/REST/V1/Items.pm >+++ b/Koha/REST/V1/Items.pm >@@ -327,6 +327,7 @@ sub add_to_bundle { > my $link = $item->add_to_bundle( $bundle_item, $options ); > if ($add_link) { > $bundle_item->biblio->link_marc_host( { host => $item->biblio } ); >+ $item->biblio->link_marc_bundled_item( { bundled_item => $bundle_item } ); > } > return $c->render( > status => 201, >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38093
:
172395
| 172396 |
172397