Bug 18322: (follow-up) Use authorized value labels
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 13 Jun 2018 09:29:54 +0000 (10:29 +0100)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 18 Jul 2018 17:42:50 +0000 (17:42 +0000)
Rather than using the raw ccode's use the labels as defined in the
authorized values.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/Search.pm

index 77a178c..3a3a57d 100644 (file)
@@ -587,6 +587,13 @@ sub getRecords {
                                     $facet_label_value = $av->count ? $av->next->opac_description : '';
                                 }
 
+                                # also, if it's a collection code, use the name instead of the code
+                                if ( $link_value =~ /ccode/ ) {
+                                    # TODO Retrieve all authorised values at once, instead of 1 query per entry
+                                    my $av = Koha::AuthorisedValues->search({ category => 'CCODE', authorised_value => $one_facet });
+                                    $facet_label_value = $av->count ? $av->next->opac_description : '';
+                                }
+
                 # but we're down with the whole label being in the link's title.
                                 push @this_facets_array,
                                   {