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

(-)a/Koha/Biblio.pm (-22 / +19 lines)
Lines 513-545 sub components { Link Here
513
513
514
    return if (C4::Context->preference('marcflavour') ne 'MARC21');
514
    return if (C4::Context->preference('marcflavour') ne 'MARC21');
515
515
516
    if (!defined($self->{_components})) {
516
    my $marc = C4::Biblio::GetMarcBiblio({ biblionumber => $self->id });
517
        my $marc = C4::Biblio::GetMarcBiblio({ biblionumber => $self->id });
517
    my $pf001 = $marc->field('001') || undef;
518
        my $pf001 = $marc->field('001') || undef;
518
    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
519
        my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
520
521
        if (defined($pf001)) {
522
            my $pf003 = $marc->field('003') || undef;
523
            my $searchstr;
524
525
            if (!defined($pf003)) {
526
                # search for 773$w='Host001'
527
                $searchstr = "rcn='".$pf001->data()."'";
528
            } else {
529
                # search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001')
530
                $searchstr = "(rcn='".$pf001->data()."' and cni='".$pf003->data()."')";
531
                $searchstr .= " or rcn='".$pf003->data()." ".$pf001->data()."'";
532
            }
533
519
534
            my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, undef );
520
    if (defined($pf001)) {
521
        my $pf003 = $marc->field('003') || undef;
522
        my $searchstr;
535
523
536
            $self->{_components} = $results if ( defined($results) && scalar(@$results) );
524
        if (!defined($pf003)) {
525
            # search for 773$w='Host001'
526
            $searchstr = "rcn='".$pf001->data()."'";
537
        } else {
527
        } else {
538
            warn "Record $self->id has no 001";
528
            # search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001')
529
            $searchstr = "(rcn='".$pf001->data()."' and cni='".$pf003->data()."')";
530
            $searchstr .= " or rcn='".$pf003->data()." ".$pf001->data()."'";
539
        }
531
        }
532
533
        my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, undef );
534
535
        $self->{_components} = $results if ( defined($results) && scalar(@$results) );
536
    } else {
537
        warn "Record $self->id has no 001";
540
    }
538
    }
541
539
542
    return $self->{_components};
540
    return $self->{_components} || ();
543
}
541
}
544
542
545
=head3 subscriptions
543
=head3 subscriptions
546
- 

Return to bug 11175