From 67cba57b01f1911e5ac78864608fdbfb4f42d504 Mon Sep 17 00:00:00 2001
From: Lari Strand <lari.strand@koha-suomi.fi>
Date: Wed, 29 May 2024 13:53:22 +0300
Subject: [PATCH] Bug 36982: Collections facet does not get alphabetized based
 on collection descriptions

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
---
 Koha/SearchEngine/Elasticsearch/Search.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm
index 54e6e644dc..f4a316345a 100644
--- a/Koha/SearchEngine/Elasticsearch/Search.pm
+++ b/Koha/SearchEngine/Elasticsearch/Search.pm
@@ -451,10 +451,12 @@ sub _convert_facets {
     my @libraries = Koha::Libraries->search->as_list;
     my $library_names = { map { $_->branchcode => $_->branchname } @libraries };
     my @locations = Koha::AuthorisedValues->search( { category => 'LOC' } )->as_list;
+    my @collections = Koha::AuthorisedValues->search( { category => 'CCODE' } )->as_list;
     my $opac = C4::Context->interface eq 'opac' ;
     my %special = (
         itype    => { map { $_->itemtype         => $_->description } @itypes },
         location => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @locations },
+        ccode => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @collections },
         holdingbranch => $library_names,
         homebranch => $library_names
     );
-- 
2.39.2