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.

CSV column Meta key Type Description
polski_unit_price_base _polski_unit_price_base float Base unit price
polski_unit_price_unit _polski_unit_price_unit string Unit price unit
polski_unit_price_amount _polski_unit_price_product_amount float Product quantity
polski_delivery_time _polski_delivery_time_id int Delivery time ID
polski_gpsr_responsible _polski_gpsr_responsible string Responsible person (GPSR)
polski_power_supply _polski_power_supply string Power supply
polski_defect_description _polski_defect_description string Defect description
polski_withdrawal_exempt _polski_withdrawal_exempt bool Right of withdrawal exemption
polski_ingredients _polski_ingredients string Ingredients
polski_nutrients _polski_nutrients string Nutrition values
polski_nutrient_reference_unit _polski_nutrient_reference_unit string Nutrition reference quantity
polski_nutri_score _polski_nutri_score string Nutri-Score
polski_alcohol_content _polski_alcohol_content float Alcohol content
polski_place_of_origin _polski_place_of_origin string Country of origin
polski_net_filling _polski_net_filling_quantity string Net quantity
polski_gpsr_manufacturer_name _polski_gpsr_manufacturer_name string GPSR - Manufacturer name
polski_gpsr_manufacturer_address _polski_gpsr_manufacturer_address string GPSR - Manufacturer address
polski_gpsr_manufacturer_contact _polski_gpsr_manufacturer_contact string GPSR - Manufacturer contact
polski_gpsr_importer_name _polski_gpsr_importer_name string GPSR - Importer name
polski_gpsr_importer_address _polski_gpsr_importer_address string GPSR - Importer address
polski_gpsr_importer_contact _polski_gpsr_importer_contact string GPSR - Importer contact
polski_gpsr_responsible_person _polski_gpsr_responsible_person string GPSR - Responsible person
polski_gpsr_responsible_address _polski_gpsr_responsible_address string GPSR - Responsible person address
polski_gpsr_responsible_contact _polski_gpsr_responsible_contact string GPSR - Responsible person contact
polski_gpsr_product_identifier _polski_gpsr_product_identifier string GPSR - Product identifier
polski_gpsr_safety_warnings _polski_gpsr_safety_warnings string GPSR - Safety warnings
polski_gpsr_instructions _polski_gpsr_instructions string GPSR - Safety instructions
polski_durability_guarantee_months _polski_durability_guarantee_months int Guarantee of durability (months)
polski_update_period_months _polski_update_period_months int Free software updates (months)
polski_repair_info _polski_repair_info string Repair information
polski_gtin _polski_gtin string GTIN / EAN (fallback)
polski_green_claim_basis _polski_green_claim_basis string Environmental claim basis
polski_green_claim_cert_url _polski_green_claim_cert_url string Environmental certificate link
polski_green_claim_expiry _polski_green_claim_expiry string Environmental certificate expiry
ID,SKU,Name,polski_gpsr_manufacturer_name,polski_gpsr_manufacturer_address,polski_gpsr_manufacturer_contact,polski_gtin,polski_place_of_origin,polski_unit_price_base,polski_unit_price_unit,polski_delivery_time
123,SKU-001,"Cotton T-shirt","Producer XYZ Sp. z o.o.","ul. Fabryczna 1, 00-001 Warsaw","contact@xyz.pl","5901234123457","PL",1,"szt",12
456,SKU-002,"Rapeseed oil 1L","Olejarnia ABC","ul. Polna 5, 60-001 Poznan","info@abc.pl","5901234567890","PL",1,"l",8
  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
Terminal window
wp wc product_csv_importer run /path/to/file.csv --user=admin
// The plugin adds no import filter of its own. Its columns are written by
// WooCommerce's own hook, so anything that runs after it wins.
add_filter('woocommerce_product_import_inserted_product_object', function ($product, $data) {
if (! empty($data['polski_gtin']) && strlen((string) $data['polski_gtin']) !== 13) {
$product->update_meta_data('_polski_gtin', '');
}
return $product;
}, 20, 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
Terminal window
wp wc product_csv_exporter run --filename=products-polski.csv --user=admin
// Columns are registered through WooCommerce's own export hooks, so add
// your own the same way the plugin does.
add_filter('woocommerce_product_export_column_names', function (array $columns): array {
$columns['custom_field'] = 'Custom field';
return $columns;
});
add_filter('woocommerce_product_export_product_column_custom_field', function ($value, $product) {
return $product->get_meta('_my_custom_field');
}, 10, 2);

Very little, deliberately. Each mapped column is passed through WordPress’s sanitize_text_field() and written to the product as-is. The one exception is the nutrition column, which is parsed from its name=value list back into the structure the plugin stores.

Nothing verifies a GTIN check digit, an email address, a country code, an allergen name or a Nutri-Score letter, and nothing is written to a separate import log. A wrong value imports as a wrong value, so check the file before the run rather than after it.

Repeating the same GPSR data across products

Section titled “Repeating the same GPSR data across products”

There is no defaults screen to fall back on: the GPSR settings cover the display mode and the section title, nothing else. To give many products the same manufacturer, repeat the column in every row of the CSV, which a spreadsheet fills down in one drag:

ID,polski_gpsr_manufacturer_name,polski_gpsr_manufacturer_address,polski_gpsr_manufacturer_contact
123,"Producer XYZ Sp. z o.o.","ul. Fabryczna 1, 00-001 Warsaw","contact@xyz.pl"
124,"Producer XYZ Sp. z o.o.","ul. Fabryczna 1, 00-001 Warsaw","contact@xyz.pl"

An import updates only the columns present in the file, so a CSV holding just the ID and the GPSR columns leaves every other product field alone.

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.