Skip to content

Commit

Permalink
feat: new import_images.pl script for pro platform (#11225)
Browse files Browse the repository at this point in the history
The import of images in the pro platform is currently tied to the import
of product data: we import images only of they come with product data.

Some producers can send us product photos in bulk, without sending
product data at the same time.

The new image_import.pl script is to load those photos. The script
essentially uses existing code from Import.pm (which has been moved a
bit in separate functions).

---------

Co-authored-by: Pierre Slamich <pierre@openfoodfacts.org>
Co-authored-by: Alex Garel <alex@openfoodfacts.org>
  • Loading branch information
3 people authored Jan 22, 2025
1 parent 68360de commit a46c967
Show file tree
Hide file tree
Showing 10 changed files with 575 additions and 274 deletions.
2 changes: 1 addition & 1 deletion cgi/product_image_move.pl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
exit(0);
}

my $product_ref = product_exists($product_id); # returns 0 if not
my $product_ref = retrieve_product($product_id);

if (not $product_ref) {
$log->warn("product does not exist", {code => $code, product_id => $product_id});
Expand Down
2 changes: 1 addition & 1 deletion cgi/product_image_upload.pl
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
exit(0);
}

my $product_ref = product_exists($product_id); # returns 0 if not
my $product_ref = retrieve_product($product_id);

if (not $product_ref) {
$log->info("product code does not exist yet, creating product", {code => $code});
Expand Down
2 changes: 1 addition & 1 deletion cgi/product_multilingual.pl
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ ($product_ref)
$product_id = product_id_for_owner($Owner_id, $code);
$log->debug("we have a code", {code => $code, product_id => $product_id}) if $log->is_debug();

$product_ref = product_exists($product_id); # returns 0 if not
$product_ref = retrieve_product($product_id);

if ($product_ref) {
$log->info("product exists, redirecting to page", {code => $code}) if $log->is_info();
Expand Down
4 changes: 2 additions & 2 deletions cgi/search.pl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
use ProductOpener::Display qw/:all/;
use ProductOpener::HTTP qw/write_cors_headers/;
use ProductOpener::Users qw/$Owner_id/;
use ProductOpener::Products qw/normalize_code normalize_search_terms product_exists product_id_for_owner product_url/;
use ProductOpener::Products qw/normalize_code normalize_search_terms retrieve_product product_id_for_owner product_url/;
use ProductOpener::Food qw/%nutriments_lists/;
use ProductOpener::Tags qw/:all/;
use ProductOpener::PackagerCodes qw/normalize_packager_codes/;
Expand Down Expand Up @@ -166,7 +166,7 @@
if ((defined $code) and (length($code) > 0)) {
my $product_id = product_id_for_owner($Owner_id, $code);

my $product_ref = product_exists($product_id); # returns 0 if not
my $product_ref = retrieve_product($product_id);

if ($product_ref) {
$log->info("product code exists, redirecting to product page", {code => $code});
Expand Down
Loading

0 comments on commit a46c967

Please sign in to comment.