batch import: do not ersatz MARC item fields
authorGalen Charlton <galen.charlton@liblime.com>
Thu, 3 Jan 2008 18:36:43 +0000 (12:36 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Thu, 3 Jan 2008 22:26:41 +0000 (16:26 -0600)
Batch import was not removing item fields (e.g., 952
or 995) from MARC records.

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>

C4/ImportBatch.pm

index 764b8bd..ca2378a 100644 (file)
@@ -458,7 +458,15 @@ sub BatchCommitBibRecords {
         if ($rowref->{'status'} eq 'error' or $rowref->{'status'} eq 'imported') {
             $num_ignored++;
         }
+
         my $marc_record = MARC::Record->new_from_usmarc($rowref->{'marc'});
+
+        # remove any item tags - rely on BatchCommitItems
+        my ($item_tag,$item_subfield) = &GetMarcFromKohaField("items.itemnumber",'');
+        foreach my $item_field ($marc_record->field($item_tag)) {
+            $marc_record->delete_field($item_field);
+        }
+
         if ($overlay_action eq 'create_new' or
             ($overlay_action eq 'replace' and $rowref->{'overlay_status'} eq 'no_match')) {
             $num_added++;
@@ -479,7 +487,6 @@ sub BatchCommitBibRecords {
             # remove item fields so that they don't get
             # added again if record is reverted
             my $old_marc = MARC::Record->new_from_xml($oldxml, 'UTF-8', $rowref->{'encoding'});
-            my ($item_tag,$item_subfield) = &GetMarcFromKohaField("items.itemnumber",'');
             foreach my $item_field ($old_marc->field($item_tag)) {
                 $old_marc->delete_field($item_field);
             }