Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not localize ecoscore on obf,opf,opff #10837

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/ProductOpener/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ use ProductOpener::APIProductRevert qw/revert_product_api/;
use ProductOpener::APIProductServices qw/product_services_api/;
use ProductOpener::APITagRead qw/read_tag_api/;
use ProductOpener::APITaxonomySuggestions qw/taxonomy_suggestions_api/;
use ProductOpener::ProductsFeatures qw(feature_enabled);

use CGI qw(header);
use Apache2::RequestIO();
Expand Down Expand Up @@ -693,7 +694,9 @@ sub customize_response_for_product ($request_ref, $product_ref, $fields_comma_se
}

# Localize the Eco-Score fields that depend on the country of the request
localize_ecoscore($request_ref->{cc}, $product_ref);
if (feature_enabled("ecoscore", $product_ref)) {
localize_ecoscore($request_ref->{cc}, $product_ref);
}

# lets compute each requested field
foreach my $field (@fields) {
Expand Down
4 changes: 3 additions & 1 deletion lib/ProductOpener/Export.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ use ProductOpener::Food qw/%nutriments_tables/;
use ProductOpener::Data qw/get_products_collection/;
use ProductOpener::Products qw/add_images_urls_to_product product_path/;
use ProductOpener::Ecoscore qw/localize_ecoscore/;
use ProductOpener::ProductsFeatures qw(feature_enabled);

use Text::CSV;
use Excel::Writer::XLSX;
Expand Down Expand Up @@ -527,7 +528,8 @@ sub export_csv ($args_ref) {
$field =~ s/^off://;

# Localize the Eco-Score fields that depend on the country of the request
if (($field =~ /^ecoscore/) and (not $ecoscore_localized)) {
if (feature_enabled("ecoscore", $product_ref) and ($field =~ /^ecoscore/) and (not $ecoscore_localized))
{
localize_ecoscore($export_cc, $product_ref);
$ecoscore_localized = 1;
}
Expand Down
Loading