View | Details | Raw Unified | Return to bug 35579
Collapse All | Expand All

(-)a/C4/Record.pm (-6 / +8 lines)
Lines 576-584 sub marcrecord2csv { Link Here
576
                # If it is a subfield
576
                # If it is a subfield
577
                my @loop_values;
577
                my @loop_values;
578
                if (defined $tag->{subfieldtag} ) {
578
                if (defined $tag->{subfieldtag} ) {
579
                    my $av = Koha::AuthorisedValues->search_by_marc_field({ frameworkcode => $frameworkcode, tagfield => $tag->{fieldtag}, tagsubfield => $tag->{subfieldtag}, });
579
                    my $av_description_mapping = Koha::AuthorisedValues->get_descriptions_by_marc_field(
580
                    $av = $av->count ? $av->unblessed : [];
580
                        {
581
                    my $av_description_mapping = { map { ( $_->{authorised_value} => $_->{lib} ) } @$av };
581
                            frameworkcode => $frameworkcode, tagfield => $tag->{fieldtag},
582
                            tagsubfield   => $tag->{subfieldtag},
583
                        }
584
                    );
582
                    # For each field
585
                    # For each field
583
                    foreach my $field (@fields) {
586
                    foreach my $field (@fields) {
584
                        my @subfields = $field->subfield( $tag->{subfieldtag} );
587
                        my @subfields = $field->subfield( $tag->{subfieldtag} );
Lines 589-597 sub marcrecord2csv { Link Here
589
592
590
                # Or a field
593
                # Or a field
591
                } else {
594
                } else {
592
                    my $av = Koha::AuthorisedValues->search_by_marc_field({ frameworkcode => $frameworkcode, tagfield => $tag->{fieldtag}, });
595
                    my $authvalues = Koha::AuthorisedValues->get_descriptions_by_marc_field(
593
                    $av = $av->count ? $av->unblessed : [];
596
                        { frameworkcode => $frameworkcode, tagfield => $tag->{fieldtag}, } );
594
                    my $authvalues = { map { ( $_->{authorised_value} => $_->{lib} ) } @$av };
595
597
596
                    foreach my $field ( @fields ) {
598
                    foreach my $field ( @fields ) {
597
                        my $value;
599
                        my $value;
(-)a/Koha/AuthorisedValues.pm (-1 / +32 lines)
Lines 141-146 sub get_descriptions_by_koha_field { Link Here
141
    return @descriptions;
141
    return @descriptions;
142
}
142
}
143
143
144
=head3 get_descriptions_by_marc_field
145
146
    Return cached descriptions when looking up by MARC field/subfield
147
148
=cut
149
150
sub get_descriptions_by_marc_field {
151
    my ( $self, $params ) = @_;
152
    my $frameworkcode = $params->{frameworkcode} || '';
153
    my $tagfield      = $params->{tagfield};
154
    my $tagsubfield   = $params->{tagsubfield};
155
156
    return {} unless defined $params->{tagfield};
157
158
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance;
159
    my $cache_key    = "AV_descriptions_by_MARC:$frameworkcode:$tagfield";
160
    if ($tagsubfield) {
161
        $cache_key .= ":$tagsubfield";
162
    }
163
164
    my $cached = $memory_cache->get_from_cache($cache_key);
165
    return $cached if $cached;
166
167
    my $descriptions = {};
168
    my @avs          = $self->search_by_marc_field($params)->as_list;
169
    foreach my $av (@avs) {
170
        $descriptions->{ $av->authorised_value } = $av->lib;
171
    }
172
    $memory_cache->set_in_cache( $cache_key, $descriptions );
173
    return $descriptions;
174
}
175
144
sub categories {
176
sub categories {
145
    my ( $self ) = @_;
177
    my ( $self ) = @_;
146
    my $rs = $self->_resultset->search(
178
    my $rs = $self->_resultset->search(
147
- 

Return to bug 35579