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