-} else {
- for my $itm (@items) {
- my $item = Koha::Items->find( $itm->{itemnumber} );
- $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
- $itm->{priority} = $priority{ $itm->{itemnumber} };
-
- $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
- unless $allow_onshelf_holds;
-
- # get collection code description, too
- my $ccode = $itm->{'ccode'};
- $itm->{'ccode'} = $collections->{$ccode} if defined($ccode) && $collections && exists( $collections->{$ccode} );
- my $copynumber = $itm->{'copynumber'};
- $itm->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumbers) && defined($copynumber) && exists( $copynumbers->{$copynumber} ) );
- if ( defined $itm->{'location'} ) {
- $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} };
- }
- if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
- $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
- $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description};
- }
- foreach (qw(ccode materials enumchron copynumber itemnotes location_description uri)) {
- $itemfields{$_} = 1 if ($itm->{$_});
- }
+}
+else {
+ my $library_info;
+ while ( my $item = $items->next ) {
+ my $item_info = $item->unblessed;
+ $item_info->{holds_count} = $item_reserves{ $item->itemnumber };
+ $item_info->{priority} = $priority{ $item->itemnumber };
+
+ # Get opac_info from Additional contents for home and holding library
+ my ( $opac_info_home, $opac_info_holding );
+ $opac_info_holding = $library_info->{ $item->holdingbranch } // $item->holding_branch->opac_info({ lang => $lang });
+ $library_info->{ $item->holdingbranch } = $opac_info_holding;
+ $opac_info_home = $library_info->{ $item->homebranch } // $item->home_branch->opac_info({ lang => $lang });
+ $library_info->{ $item->homebranch } = $opac_info_home;
+ $item_info->{holding_library_info} = $opac_info_holding->content if $opac_info_holding;
+ $item_info->{home_library_info} = $opac_info_home->content if $opac_info_home;
+
+ $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy(
+ { item => $item, patron => $patron } )
+ unless $allow_onshelf_holds;
+
+ # get collection code description, too
+ my $ccode = $item->ccode;
+ $item_info->{'ccode'} = $collections->{$ccode}
+ if defined($ccode)
+ && $collections
+ && exists( $collections->{$ccode} );
+
+ my $copynumber = $item->copynumber;
+ $item_info->{copynumber} = $copynumbers->{$copynumber}
+ if ( defined($copynumbers)
+ && defined($copynumber)
+ && exists( $copynumbers->{$copynumber} ) );
+
+ if ( defined $item->location ) {
+ $item_info->{'location_description'} =
+ $shelflocations->{ $item->location };
+ }