View | Details | Raw Unified | Return to bug 37564
Collapse All | Expand All

(-)a/C4/Items.pm (-5 / +6 lines)
Lines 226-235 Additional information appropriate to the error condition. Link Here
226
=cut
226
=cut
227
227
228
sub AddItemBatchFromMarc {
228
sub AddItemBatchFromMarc {
229
    my ( $record, $biblionumber, $biblioitemnumber, $frameworkcode ) = @_;
229
    my ( $record, $biblionumber, $biblioitemnumber, $frameworkcode, $options ) = @_;
230
    my @itemnumbers = ();
230
    my @itemnumbers      = ();
231
    my @errors      = ();
231
    my @errors           = ();
232
    my $dbh         = C4::Context->dbh;
232
    my $dbh              = C4::Context->dbh;
233
    my $skip_holds_queue = $options->{skip_holds_queue} // 0;
233
234
234
    # We modify the record, so lets work on a clone so we don't change the
235
    # We modify the record, so lets work on a clone so we don't change the
235
    # original.
236
    # original.
Lines 266-272 ITEMFIELD: foreach my $item_field ( $record->field($itemtag) ) { Link Here
266
            next ITEMFIELD;
267
            next ITEMFIELD;
267
        }
268
        }
268
269
269
        my $item_object = Koha::Item->new($item)->store;
270
        my $item_object = Koha::Item->new($item)->store( { skip_holds_queue => $skip_holds_queue } );
270
        push @itemnumbers, $item_object->itemnumber;                          # FIXME not checking error
271
        push @itemnumbers, $item_object->itemnumber;                          # FIXME not checking error
271
272
272
        logaction( "CATALOGUING", "ADD", $item_object->itemnumber, "item" )
273
        logaction( "CATALOGUING", "ADD", $item_object->itemnumber, "item" )
(-)a/misc/migration_tools/bulkmarcimport.pl (-6 / +14 lines)
Lines 134-145 my $using_elastic_search = ( C4::Context->preference('SearchEngine') eq 'Elastic Link Here
134
my $mod_biblio_options   = {
134
my $mod_biblio_options   = {
135
    disable_autolink  => $using_elastic_search,
135
    disable_autolink  => $using_elastic_search,
136
    skip_record_index => $using_elastic_search || $skip_indexing,
136
    skip_record_index => $using_elastic_search || $skip_indexing,
137
    skip_holds_queue  => 1,
137
    overlay_context   => { source => 'bulkmarcimport' }
138
    overlay_context   => { source => 'bulkmarcimport' }
138
};
139
};
139
my $add_biblio_options = {
140
my $add_biblio_options = {
140
    disable_autolink  => $using_elastic_search,
141
    disable_autolink  => $using_elastic_search,
141
    skip_record_index => $using_elastic_search || $skip_indexing
142
    skip_record_index => $using_elastic_search || $skip_indexing,
143
    skip_holds_queue  => 1,
142
};
144
};
145
143
my $mod_authority_options = { skip_record_index => $using_elastic_search || $skip_indexing };
146
my $mod_authority_options = { skip_record_index => $using_elastic_search || $skip_indexing };
144
my $add_authority_options = { skip_record_index => $using_elastic_search || $skip_indexing };
147
my $add_authority_options = { skip_record_index => $using_elastic_search || $skip_indexing };
145
148
Lines 329-335 $schema->txn_begin; Link Here
329
RECORD: while () {
332
RECORD: while () {
330
333
331
    my $record;
334
    my $record;
332
    $record_number++;
333
335
334
    # get record
336
    # get record
335
    eval { $record = $batch->next() };
337
    eval { $record = $batch->next() };
Lines 542-547 RECORD: while () { Link Here
542
                }
544
                }
543
            } else {
545
            } else {
544
                my ( $biblioitemnumber, $itemnumbers_ref, $errors_ref, $record_id );
546
                my ( $biblioitemnumber, $itemnumbers_ref, $errors_ref, $record_id );
547
                my $add_item_options = {};    # Will need to set this for each record
545
548
546
                # check for duplicate, based on ISBN (skip it if we already have found a duplicate with match parameter
549
                # check for duplicate, based on ISBN (skip it if we already have found a duplicate with match parameter
547
                if ( !$matched_record_id && $isbn_check && $isbn ) {
550
                if ( !$matched_record_id && $isbn_check && $isbn ) {
Lines 563-568 RECORD: while () { Link Here
563
566
564
                # Create biblio, unless we already have it (either match or ISBN)
567
                # Create biblio, unless we already have it (either match or ISBN)
565
                if ($matched_record_id) {
568
                if ($matched_record_id) {
569
                    $add_item_options->{skip_holds_queue} =
570
                        0;    #Existing record found, either updating or ignoring, need to update the queue
571
566
                    eval { $biblioitemnumber = Koha::Biblios->find($matched_record_id)->biblioitem->biblioitemnumber; };
572
                    eval { $biblioitemnumber = Koha::Biblios->find($matched_record_id)->biblioitem->biblioitemnumber; };
567
                    if ($update) {
573
                    if ($update) {
568
                        my $success;
574
                        my $success;
Lines 594-599 RECORD: while () { Link Here
594
                        ) if ($logfile);
600
                        ) if ($logfile);
595
                    }
601
                    }
596
                } elsif ($insert) {
602
                } elsif ($insert) {
603
                    $add_item_options->{skip_holds_queue} = 1;    # New record, no need to update the queue
597
                    my $record_clone = $record->clone();
604
                    my $record_clone = $record->clone();
598
                    C4::Biblio::_strip_item_fields($record_clone);
605
                    C4::Biblio::_strip_item_fields($record_clone);
599
                    eval {
606
                    eval {
Lines 626-633 RECORD: while () { Link Here
626
                if ($record_id) {
633
                if ($record_id) {
627
                    $yamlhash->{$originalid} = $record_id if $yamlfile;
634
                    $yamlhash->{$originalid} = $record_id if $yamlfile;
628
                    eval {
635
                    eval {
629
                        ( $itemnumbers_ref, $errors_ref ) =
636
                        ( $itemnumbers_ref, $errors_ref ) = AddItemBatchFromMarc(
630
                            AddItemBatchFromMarc( $record, $record_id, $biblioitemnumber, $framework );
637
                            $record, $record_id, $biblioitemnumber, $framework,
638
                            $add_item_options
639
                        );
631
                    };
640
                    };
632
                    my $error_adding = $@;
641
                    my $error_adding = $@;
633
642
Lines 680-686 RECORD: while () { Link Here
680
                        my $more_errors;
689
                        my $more_errors;
681
                        eval {
690
                        eval {
682
                            ( $itemnumbers_ref, $more_errors ) =
691
                            ( $itemnumbers_ref, $more_errors ) =
683
                                AddItemBatchFromMarc( $record, $record_id, $biblioitemnumber, '' );
692
                                AddItemBatchFromMarc( $record, $record_id, $biblioitemnumber, '', $add_item_options );
684
                        };
693
                        };
685
                        if ($@) {
694
                        if ($@) {
686
                            warn "ERROR: Adding items to bib $record_id failed: $@\n";
695
                            warn "ERROR: Adding items to bib $record_id failed: $@\n";
687
- 

Return to bug 37564