@@ -, +, @@ (follow-up) inventory --- t/db_dependent/Items/GetItemsForInventory.t | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/t/db_dependent/Items/GetItemsForInventory.t +++ a/t/db_dependent/Items/GetItemsForInventory.t @@ -137,6 +137,7 @@ sub OldWay { $sth->execute( @bind_params ); my ($iTotalRecords) = $sth->fetchrow_array(); + my $marc_field_mapping; foreach my $row (@$tmpresults) { # Auth values @@ -145,9 +146,14 @@ sub OldWay { 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}}; } } --