From 8736b420eaa9fd17e6a9a201adf3c6c3e65741d7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 2 Sep 2021 12:10:19 +0100 Subject: [PATCH] Bug 21469: Add 003 into 773$w when required This patch looks at the MarcOrgCode preference and if present it will prepend the host 003 data in brackets to the 773$w link field in the child record. --- C4/Biblio.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 4b32ad43d52..2b3895dd7bf 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2937,7 +2937,8 @@ sub ModBiblioMarc { =head2 prepare_host_field -$marcfield = prepare_host_field( $hostbiblioitem, $marcflavour ); + $marcfield = prepare_host_field( $hostbiblioitem, $marcflavour ); + Generate the host item entry for an analytic child entry =cut @@ -2954,6 +2955,11 @@ sub prepare_host_field { my $field; my $host_field; if ( $marcflavour eq 'MARC21' ) { + my $userenv = C4::Context->userenv; + my $library; + if ( $userenv && $userenv->{'branch'} ) { + $library = Koha::Libraries->find( $userenv->{'branch'} ); + } if ( $field = $host->field('100') || $host->field('110') || $host->field('11') ) { my $s = $field->as_string('ab'); if ($s) { @@ -2991,7 +2997,12 @@ sub prepare_host_field { } } if ( $field = $host->field('001') ) { - $sfd{w} = $field->data(),; + $sfd{w} = $field->data(); + if ( $library->get_effective_marcorgcode ) { + if ( $field = $host->field('003') ) { + $sft{w} = "(" . $field->data() . ")" . $sft{w}; + } + } } $host_field = MARC::Field->new( 773, '0', ' ', %sfd ); return $host_field; -- 2.45.2