Skip to content

Commit

Permalink
fix: do not localize ecoscore on obf,opf,opff (#10837)
Browse files Browse the repository at this point in the history
- Might solve
#10835
  • Loading branch information
stephanegigandet authored Sep 27, 2024
1 parent 62e12d6 commit 2f93877
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"errors" : [
{
"field" : {
"error" : "'null' expected, at character offset 0 (before \"not json\") at /opt/product-opener/lib/ProductOpener/API.pm line 225.\n",
"error" : "'null' expected, at character offset 0 (before \"not json\") at /opt/product-opener/lib/ProductOpener/API.pm line 226.\n",
"id" : "body",
"value" : "not json"
},
Expand Down

0 comments on commit 2f93877

Please sign in to comment.