Skip to content

CSV import and export

Extension of the WooCommerce CSV importer/exporter with columns for legal data, GPSR, environmental claims and other fields required by Polish and EU law.

GPSR fields (General Product Safety Regulation)

Section titled “GPSR fields (General Product Safety Regulation)”
CSV columnMeta keyTypeDescription
gpsr_manufacturer_name_polski_gpsr_manufacturer_namestringManufacturer name
gpsr_manufacturer_address_polski_gpsr_manufacturer_addressstringManufacturer address
gpsr_manufacturer_email_polski_gpsr_manufacturer_emailstringManufacturer email
gpsr_manufacturer_phone_polski_gpsr_manufacturer_phonestringManufacturer phone
gpsr_manufacturer_url_polski_gpsr_manufacturer_urlstringManufacturer website
gpsr_authorized_rep_name_polski_gpsr_auth_rep_namestringAuthorized representative name
gpsr_authorized_rep_address_polski_gpsr_auth_rep_addressstringAuthorized representative address
gpsr_authorized_rep_email_polski_gpsr_auth_rep_emailstringAuthorized representative email
gpsr_safety_info_polski_gpsr_safety_infostringSafety information
gpsr_warnings_polski_gpsr_warningsstringProduct warnings
gpsr_barcode_type_polski_gpsr_barcode_typestringBarcode type: EAN, UPC, GTIN
gpsr_barcode_value_polski_gpsr_barcode_valuestringBarcode value
gpsr_product_type_polski_gpsr_product_typestringProduct type per GPSR
gpsr_country_of_origin_polski_gpsr_country_originstringCountry of origin (ISO code)
CSV columnMeta keyTypeDescription
green_claim_text_polski_green_claimstringEnvironmental claim content
green_claim_evidence_polski_green_evidencestringEvidence / justification
green_certification_name_polski_green_cert_namestringCertificate name
green_certification_number_polski_green_cert_numberstringCertificate number
green_certification_url_polski_green_cert_urlstringCertificate link
green_carbon_footprint_polski_green_carbonfloatCarbon footprint (kg CO2)
green_recyclable_polski_green_recyclableboolWhether product is recyclable
green_durability_years_polski_green_durabilityintProduct durability in years
CSV columnMeta keyTypeDescription
unit_price_polski_unit_pricefloatUnit price
unit_price_unit_polski_unit_price_unitstringUnit: kg, l, m, pcs
unit_price_base_polski_unit_price_basefloatConversion base
delivery_time_min_polski_delivery_minintMin. delivery time (days)
delivery_time_max_polski_delivery_maxintMax. delivery time (days)
manufacturer_name_polski_manufacturerstringManufacturer name
manufacturer_url_polski_manufacturer_urlstringManufacturer URL
gtin_polski_gtinstringGTIN/EAN code
withdrawal_excluded_polski_withdrawal_excludedboolExcluded from withdrawal right
withdrawal_reason_polski_withdrawal_reasonstringWithdrawal exclusion reason
CSV columnMeta keyTypeDescription
energy_kcal_polski_energy_kcalfloatEnergy (kcal/100g)
energy_kj_polski_energy_kjfloatEnergy (kJ/100g)
fat_polski_fatfloatFat (g/100g)
saturated_fat_polski_saturated_fatfloatSaturated fatty acids
carbohydrates_polski_carbohydratesfloatCarbohydrates (g/100g)
sugars_polski_sugarsfloatSugars (g/100g)
protein_polski_proteinfloatProtein (g/100g)
salt_polski_saltfloatSalt (g/100g)
fiber_polski_fiberfloatFibre (g/100g)
allergens_polski_allergensstringAllergens (comma-separated)
nutri_score_polski_nutri_scorestringNutri-Score: A, B, C, D, E
ID,SKU,Name,gpsr_manufacturer_name,gpsr_manufacturer_address,gpsr_manufacturer_email,gpsr_barcode_type,gpsr_barcode_value,gpsr_country_of_origin,unit_price,unit_price_unit,delivery_time_min,delivery_time_max,manufacturer_name
123,SKU-001,"Cotton T-shirt","Producer XYZ Sp. z o.o.","ul. Fabryczna 1, 00-001 Warsaw","[email protected]","EAN","5901234123457","PL",49.99,"pcs",2,5,"XYZ"
456,SKU-002,"Rapeseed oil 1L","Olejarnia ABC","ul. Polna 5, 60-001 Poznan","[email protected]","EAN","5901234567890","PL",12.99,"l",1,3,"ABC"
  1. Go to WooCommerce > Products > Import
  2. Select the CSV file
  3. At the column mapping stage - Polski for WooCommerce columns will appear automatically in the Polski for WooCommerce section
  4. Map CSV columns to the appropriate fields
  5. Run the import
Okno terminala
wp wc product_csv_importer run /path/to/file.csv --user=admin
// Hook to modify imported data
add_filter('polski/csv/import_data', function (array $data, array $raw_row): array {
// GTIN code validation
if (!empty($data['gpsr_barcode_value'])) {
$gtin = $data['gpsr_barcode_value'];
if (strlen($gtin) !== 13 && strlen($gtin) !== 8) {
$data['gpsr_barcode_value'] = ''; // Reject invalid code
}
}
return $data;
}, 10, 2);
  1. Go to WooCommerce > Products > Export
  2. In the Columns to export section, check columns from the Polski for WooCommerce group
  3. Optionally filter by category, status or product type
  4. Click Generate CSV
Okno terminala
wp wc product_csv_exporter run --filename=products-polski.csv --user=admin
// Adding custom columns to export
add_filter('polski/csv/export_columns', function (array $columns): array {
$columns['custom_field'] = 'Custom field';
return $columns;
});
// Custom column value
add_filter('polski/csv/export_column_value', function ($value, string $column, WC_Product $product) {
if ($column === 'custom_field') {
return $product->get_meta('_my_custom_field');
}
return $value;
}, 10, 3);

Import automatically validates data:

  • GTIN/EAN - check digit verification (modulo 10 algorithm)
  • Email - email address format validation
  • URL - URL format validation
  • Country - ISO 3166-1 alpha-2 code check
  • Allergens - verification that values belong to the defined list (14 EU allergens)
  • Nutri-Score - check that the value is A, B, C, D or E

Invalid values are logged and skipped (they do not block the import). The log is available after import in the results section.

For stores with a large number of products where the manufacturer is shared across many products:

Okno terminala
# Prepare a CSV with minimal data
# ID,gpsr_manufacturer_name,gpsr_manufacturer_address,gpsr_manufacturer_email

Then set default GPSR values in WooCommerce > Polski > Legal Compliance > GPSR > Default values. The import will only fill in products that have empty GPSR fields.

Polski columns do not appear in mapping - make sure the Polski for WooCommerce plugin is active. Columns are registered via the woocommerce_csv_product_import_mapping_options hook.

Import times out - increase PHP max_execution_time or use WP-CLI for importing large files.

Special characters are corrupted - make sure the CSV file is saved in UTF-8 encoding (without BOM).

Numeric values do not import - the decimal separator in the CSV file should be a dot (.), not a comma.

Report issues: github.com/wppoland/polski/issues

This page is for informational purposes only and does not constitute legal advice. Consult a lawyer before implementation. Polski for WooCommerce is open source software (GPLv2) provided without warranty.