From 5dcfef1713eb8b37b3850098a6e5610bca919f41 Mon Sep 17 00:00:00 2001 From: Success Ologunsua Date: Thu, 28 Mar 2024 11:00:14 +0100 Subject: [PATCH] fix: Add a new sheet for categories to the import spreadsheet template (#9925) --- cgi/generate_sample_import_file.pl | 10 ++++++++++ lib/ProductOpener/TaxonomySuggestions.pm | 1 + 2 files changed, 11 insertions(+) diff --git a/cgi/generate_sample_import_file.pl b/cgi/generate_sample_import_file.pl index 7727c8697de2d..a26dd8b61073b 100755 --- a/cgi/generate_sample_import_file.pl +++ b/cgi/generate_sample_import_file.pl @@ -35,6 +35,7 @@ use ProductOpener::Producers qw/generate_import_export_columns_groups_for_select2/; use ProductOpener::Tags qw/%language_fields %tags_fields/; use ProductOpener::Food qw/default_unit_for_nid/; +use ProductOpener::TaxonomySuggestions qw/:all/; use Apache2::RequestRec (); use Apache2::Const (); @@ -54,6 +55,8 @@ my $workbook = Excel::Writer::XLSX->new(\*STDOUT); my $worksheet = $workbook->add_worksheet(); +my $worksheet_categories = $workbook->add_worksheet(lang("categories")); + my %formats = ( normal => $workbook->add_format(border => 1, bold => 1), mandatory => $workbook->add_format( @@ -249,4 +252,11 @@ } } +my $tagtype = "categories"; +my @category_entries = ProductOpener::TaxonomySuggestions::generate_sorted_list_of_taxonomy_entries($tagtype, $lc, {}); +foreach my $i (0 .. $#category_entries) { + my $category_entry = display_taxonomy_tag($lc, $tagtype, $category_entries[$i]); + $worksheet_categories->write($i, 0, $category_entry); +} + exit(0); diff --git a/lib/ProductOpener/TaxonomySuggestions.pm b/lib/ProductOpener/TaxonomySuggestions.pm index befb3c8cd3228..642108e4481a7 100644 --- a/lib/ProductOpener/TaxonomySuggestions.pm +++ b/lib/ProductOpener/TaxonomySuggestions.pm @@ -38,6 +38,7 @@ BEGIN { @EXPORT_OK = qw( &get_taxonomy_suggestions_with_synonyms &get_taxonomy_suggestions + &generate_sorted_list_of_taxonomy_entries ); # symbols to export on request %EXPORT_TAGS = (all => [@EXPORT_OK]); }