From 6dd447b36e09cc3bc94eff78b972f6c141549c24 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Wed, 19 Jul 2023 10:51:48 +0100 Subject: [PATCH] Revert "Bug 33497: Use 'host_items' param to fetch all items at once" This reverts commit dc273a8dfe384b7c847a23b842f1dde601537d82. --- catalogue/detail.pl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 3cd9dd7cb9..1f6abecd73 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -194,14 +194,20 @@ 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->search_ordered( $params )->as_list; # flag indicating existence of at least one item linked via a host record -my $hostrecords = $biblio->host_items->count; +my $hostrecords; +# adding items linked via host biblios +my $hostitems = $biblio->host_items; +if ( $hostitems->count ) { + $hostrecords = 1; + push @items, $hostitems->as_list; +} my $dat = &GetBiblioData($biblionumber); -$dat->{'count'} = $biblio->items({ host_items => 1 })->count; -$dat->{'showncount'} = $items->count; +$dat->{'count'} = $biblio->items->count + $hostitems->count; +$dat->{'showncount'} = scalar @items; $dat->{'hiddencount'} = $dat->{'count'} - $dat->{'showncount'}; #is biblio a collection and are bundles enabled @@ -358,7 +364,7 @@ if ($currentbranch and C4::Context->preference('SeparateHoldings')) { my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch'; my ( $itemloop_has_images, $otheritemloop_has_images ); -while ( my $item = $items->next ) { +foreach my $item (@items) { my $itembranchcode = $item->$separatebranch; my $item_info = $item->unblessed; @@ -532,7 +538,7 @@ $template->param( materials => $materials_flag, ); -if (C4::Context->preference("AlternateHoldingsField") && scalar $items->count == 0) { +if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) { my $fieldspec = C4::Context->preference("AlternateHoldingsField"); my $subfields = substr $fieldspec, 3; my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; -- 2.39.2