$sth->execute( @bind_params );
my ($iTotalRecords) = $sth->fetchrow_array();
+ my $marc_field_mapping;
foreach my $row (@$tmpresults) {
# Auth values
my ($f, $sf) = C4::Biblio::GetMarcFromKohaField("items.$field", $row->{'frameworkcode'});
if (defined($f) and defined($sf)) {
# We replace the code with it's description
- my $av = Koha::AuthorisedValues->search_by_marc_field({ frameworkcode => $row->{frameworkcode}, tagfield => $f, tagsubfield => $sf, });
- $av = $av->count ? $av->unblessed : [];
- my $authvals = { map { ( $_->{authorised_value} => $_->{lib} ) } @$av };
+ my $avs;
+ if ( exists $marc_field_mapping->{$row->{frameworkcode}}{$f}{$sf} ) {
+ $avs = $marc_field_mapping->{$row->{frameworkcode}}{$f}{$sf};
+ } else {
+ $avs = Koha::AuthorisedValues->search_by_marc_field({ frameworkcode => $row->{frameworkcode}, tagfield => $f, tagsubfield => $sf, });
+ $marc_field_mapping->{$row->{frameworkcode}}{$f}{$sf} = $avs->unblessed;
+ }
+ my $authvals = { map { $_->{authorised_value} => $_->{lib} } @{ $marc_field_mapping->{$row->{frameworkcode}}{$f}{$sf} } };
$row->{$field} = $authvals->{$row->{$field}} if defined $authvals && defined $row->{$field} && defined $authvals->{$row->{$field}};
}
}