From c35d52889095b4ca4e227949fc9bda686d452c7f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 1 Feb 2023 14:06:30 +0100 Subject: [PATCH] Bug 32782: ERM UNIMARC support Create the biblio record when a resource is created Test plan: Create a new local title and confirm that the Koha bibliographic record is created correctly. Signed-off-by: Laurence Rault Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 07e37c541404b102dce4242db6b09b4a93d6931f) Signed-off-by: Martin Renvoize --- Koha/ERM/EHoldings/Resource.pm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Koha/ERM/EHoldings/Resource.pm b/Koha/ERM/EHoldings/Resource.pm index fa776cf081..2457b2d644 100644 --- a/Koha/ERM/EHoldings/Resource.pm +++ b/Koha/ERM/EHoldings/Resource.pm @@ -21,6 +21,7 @@ use MARC::Record; use Koha::Database; +use C4::Biblio qw( AddBiblio TransformKohaToMarc ); use Koha::Acquisition::Booksellers; use Koha::Biblios; use Koha::ERM::EHoldings::Titles; @@ -47,16 +48,23 @@ sub store { # FIXME This is terrible and ugly, we need to: # * Provide a mapping for each attribute of title - # * Deal with marcflavour # * Create a txn my $title = $self->title; - my $biblio = $title->biblio_id ? Koha::Biblios->find($title->biblio_id) : undef; - my $marc_record = $biblio ? $biblio->metadata->record : MARC::Record->new; - eval {$marc_record->field('245')->delete_subfield('a');}; - $marc_record->add_fields(MARC::Field->new(245, '', '', a => $title->publication_title)); + my $biblio = + $title->biblio_id + ? Koha::Biblios->find( $title->biblio_id )->unblessed + : {}; + + my $marc_record = TransformKohaToMarc( + { + %$biblio, + 'biblio.title' => $title->publication_title, + + } + ); my $biblio_id; - if ( $biblio ) { + if ( %$biblio ) { $biblio_id = $title->biblio_id; C4::Biblio::ModBiblio($marc_record, $title->biblio_id, ''); } else { -- 2.39.5