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

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

Return to bug 11175