Bug 6520: Display items for staged record
When records are imported into Koha, the items is stored into the
import_items table.
This marcxml in this table is never retrieved to display items.
Test plan:
1/ Import a records with items
2/ Before importing the batch into the catalog, you can see the marc
of the records, in the table below.
3/ Verify that the items is correctly displayed.
QA note: This patch does not provide test for new subroutines but the
module (C4::ImportBatch) is not tested at all and it will be time
consuming to provide them.
Signed-off-by: Nicole Engard <nengard@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
(cherry picked from commit 4d8dd344ae)
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
This commit is contained in:
parent
a21185e978
commit
a98b1becee
|
|
@ -169,12 +169,42 @@ sub GetImportRecordMarc {
|
|||
my ($import_record_id) = @_;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth = $dbh->prepare("SELECT marc, encoding FROM import_records WHERE import_record_id = ?");
|
||||
$sth->execute($import_record_id);
|
||||
my ($marc, $encoding) = $sth->fetchrow();
|
||||
$sth->finish();
|
||||
return $marc, $encoding;
|
||||
my ( $marc, $encoding ) = $dbh->selectrow_array(q|
|
||||
SELECT marc, encoding
|
||||
FROM import_records
|
||||
WHERE import_record_id = ?
|
||||
|, undef, $import_record_id );
|
||||
|
||||
return $marc, $encoding;
|
||||
}
|
||||
|
||||
sub GetRecordFromImportBiblio {
|
||||
my ( $import_record_id, $embed_items ) = @_;
|
||||
|
||||
my ($marc) = GetImportRecordMarc($import_record_id);
|
||||
my $record = MARC::Record->new_from_usmarc($marc);
|
||||
|
||||
EmbedItemsInImportBiblio( $record, $import_record_id ) if $embed_items;
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
sub EmbedItemsInImportBiblio {
|
||||
my ( $record, $import_record_id ) = @_;
|
||||
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber", '');
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $import_items = $dbh->selectall_arrayref(q|
|
||||
SELECT import_items.marcxml
|
||||
FROM import_items
|
||||
WHERE import_record_id = ?
|
||||
|, { Slice => {} }, $import_record_id );
|
||||
my @item_fields;
|
||||
for my $import_item ( @$import_items ) {
|
||||
my $item_marc = MARC::Record::new_from_xml($import_item->{marcxml});
|
||||
push @item_fields, $item_marc->field($itemtag);
|
||||
}
|
||||
$record->append_fields(@item_fields);
|
||||
return $record;
|
||||
}
|
||||
|
||||
=head2 GetImportRecordMarcXML
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ my $view= $input->param('viewas')||'';
|
|||
|
||||
my $record;
|
||||
if ($importid) {
|
||||
my ($marc) = GetImportRecordMarc($importid);
|
||||
$record = MARC::Record->new_from_usmarc($marc);
|
||||
$record = C4::ImportBatch::GetRecordFromImportBiblio( $importid, 'embed_items' );
|
||||
}
|
||||
else {
|
||||
$record =GetMarcBiblio($biblionumber);
|
||||
|
|
|
|||
Loading…
Reference in New Issue