@@ -, +, @@ --- Koha/Biblio.pm | 12 ++++++++++-- Koha/REST/V1/Biblios.pm | 1 + api/v1/swagger/definitions/library.yaml | 7 +++++++ 3 files changed, 18 insertions(+), 2 deletions(-) --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -371,6 +371,7 @@ sub pickup_locations { my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); my @pickup_locations; + my $location_items; foreach my $item ( $self->items->as_list ) { my $cache_key = sprintf "Pickup_locations:%s:%s:%s:%s:%s", $item->itype,$item->homebranch,$item->holdingbranch,$item->ccode || "",$patron->branchcode||"" ; @@ -379,11 +380,18 @@ sub pickup_locations { @{ $item_pickup_locations } = $item->pickup_locations( { patron => $patron } )->_resultset->get_column('branchcode')->all; $memory_cache->set_in_cache( $cache_key, $item_pickup_locations ); } - push @pickup_locations, @{ $item_pickup_locations } + push @pickup_locations, @{ $item_pickup_locations }; + for my $location (@pickup_locations) { + push @{$location_items->{$location}}, $item->itemnumber; + } } - return Koha::Libraries->search( + my $resultSet = Koha::Libraries->search( { branchcode => { '-in' => \@pickup_locations } }, { order_by => ['branchname'] } ); + + $resultSet->{_pickup_location_items} = $location_items; + + return $resultSet; } =head3 hidden_in_opac --- a/Koha/REST/V1/Biblios.pm +++ a/Koha/REST/V1/Biblios.pm @@ -573,6 +573,7 @@ sub pickup_locations { my $pickup_locations = $c->objects->search($pl_set); @response = map { $_->{needs_override} = Mojo::JSON->false; $_; } @{$pickup_locations}; } + @response = map { $_->{pickup_items} = $pl_set->{_pickup_location_items}->{ $_->{library_id} }; $_; } @response; return $c->render( status => 200, --- a/api/v1/swagger/definitions/library.yaml +++ a/api/v1/swagger/definitions/library.yaml @@ -104,6 +104,13 @@ properties: pickup_location: type: boolean description: If the library can act as a pickup location + pickup_items: + type: + - array + - "null" + description: Array of items available for pickup at this library is the library is marked as a pickup location + items: + type: integer public: type: boolean description: If the library is visible to the public --