diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index a0a70197a9..da3f623230 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -479,11 +479,10 @@ sub items { return Koha::Items->_new_from_dbic( $items_rs ) unless $params->{host_items}; + my @itemnumbers = $items_rs->get_column('itemnumber')->all; my $host_itemnumbers = $self->_host_itemnumbers(); - my $search_params = { -or => [biblionumber => $self->id] }; - push @{$search_params->{'-or'}}, itemnumber => { -in => $host_itemnumbers } if $host_itemnumbers; - - return Koha::Items->search($search_params); + push @itemnumbers, @{ $host_itemnumbers }; + return Koha::Items->search({ "me.itemnumber" => { -in => \@itemnumbers } }); } =head3 host_items diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 3cd9dd7cb9..c47b9b44a8 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -194,7 +194,7 @@ my $all_items = $biblio->items->search_ordered; my @items; my $patron = Koha::Patrons->find( $borrowernumber ); $params->{ itemlost } = 0 if $patron->category->hidelostitems && !$showallitems; -my $items = $biblio->items({ host_items => 1 })->search_ordered( $params, { prefetch => ['issue','branchtransfers'] } ); +my $items = $biblio->items({ host_items => 1 })->search_ordered( $params, { prefetch => ['issue','branchtransfer'] } ); # flag indicating existence of at least one item linked via a host record my $hostrecords = $biblio->host_items->count;