Bug 31306: Allow to pass params and attributes to search_ordered

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2022-07-29 13:06:07 +02:00 committed by Tomas Cohen Arazi
parent 999014d3e8
commit 80f784d352
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 15 additions and 3 deletions

View File

@ -407,10 +407,22 @@ Search and sort items in a specific order, depending if serials are present or n
=cut
sub search_ordered {
my ($self) = @_;
my ($self, $params, $attributes) = @_;
if ( $self->search({ select => ["enumchron IS NOT NULL"] }) ) {
return $self->search( {}, { order_by => 'enumchron' } );
$self = $self->search($params, $attributes);
my @biblionumbers = uniq $self->get_column('biblionumber');
if ( scalar ( @biblionumbers ) == 1
&& Koha::Biblios->find( $biblionumbers[0] )->serial )
{
return $self->search(
{},
{
order_by => [ 'serialid.publisheddate', 'me.enumchron' ],
join => { serialitem => 'serialid' }
}
);
} else {
return $self->search(
{},