Skip to main content

Tips for working with CSV files in Shopware

Shopware 6 — Edit CSV files correctly in Excel or LibreOffice and import them back into Shopware. Learn what to watch out for.

The CSV import and export function of Shopware is helpful when you need to change or create a large quantity of data. However, there are a few things to keep in mind when using it – especially when opening, editing, and saving the CSV files.

Below, we show you step by step for Microsoft Excel and LibreOffice Calc what you need to consider so that the CSV file is displayed correctly in your spreadsheet program and can also be imported back into Shopware correctly.

To find out which data you can export as CSV, see How do I export data from Pickware as CSV?

What is a CSV file and how does it "work"?

A CSV file is a simple text file that stores data in table form. Each row in the file corresponds to a set of data, and the values within a row are separated from each other by semicolons or other characters. Here you can see an example of the content of a CSV file that lists the absolute stock of a product at different bin locations. The first row contains the respective column names.

Produktname;Produktnummer;Lager;Lagerkürzel;Lagerplatz;Standardlagerplatz;Bestand"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;unbekannt;nein;-24"Aerodynamic Concrete CoffeeMatic";SW10071;Nachfülllager;NL;C-03-006;ja;150"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;B-02-002;nein;90"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;C-02-007;ja;50"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;C-03-004;nein;125

How is a CSV file read and processed?

1. The file is read row by row – so the order of the entries matters. This means that if an entry appears several times with different values, the later value overwrites the earlier one. Here is an example:

The last row of the example CSV file above reads as follows:

"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;C-03-004;nein;125

When this row is read, a stock of 125 is written for product SW10071 at bin location C-03-004 in the main warehouse. Suppose another row followed in the CSV file that refers to the same combination of product number, warehouse, and bin location but contains a different stock value. For example:

"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;C-03-004;nein;100

When this row is read, 100 units would not be added to the 125 units already written. Instead, the stock for product SW10071 at bin location C-03-004 in the main warehouse would be overwritten. The final stock would therefore be 100 units, not 225!

2. Only what is in the file is processed. No logical assumptions are made on its own. For example, if you want to move stock from bin location A to bin location B, your CSV file must contain two rows for this.

Here, as part of an absolute stock import, the first row books 90 units of a product to bin location A-01-001 (absolute stock = 90). The second row removes 90 units of the product from bin location B-02-002 (absolute stock = 0)

Produktname;Produktnummer;Lager;Lagerkürzel;Lagerplatz;Standardlagerplatz;Bestand"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;A-01-001;nein;90"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;B-02-002;nein;0

With a relative stock import, the same change would look like this

Produktname;Produktnummer;Lager;Lagerkürzel;Lagerplatz;Standardlagerplatz;Änderung"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;A-01-001;nein;90"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;B-02-002;nein;-90

If only the first row is included in the CSV file in each case, stock would only be booked in at the new bin location, but no stock would be booked out at the old bin location. As a result, your actual stock would be 90 units too high.

3. The place of the import determines which data can be changed. For example, in the stock overview you can only change the stock at the respective bin locations through a CSV import. If you change the product name in the import file, this has no effect on the actual product.

If you specify a bin location that does not exist, it is not created automatically. Instead, the affected record is not imported and an error message appears in the import report. To create bin locations, there is a separate import interface, where, accordingly, no stock can be changed.

General procedure

Regardless of the program you use, keep the following points in mind when editing the CSV file for the Shopware import/export tool:

  • Export the relevant profile as a CSV file from Shopware and use it as a template.

  • Open the file as a CSV file in a spreadsheet program.

  • Important: the encoding must be UTF-8 and the delimiter must be a semicolon.

  • Finally, the file must be exported or saved again as a semicolon-separated CSV file in UTF-8 format.

CSV import/export with Excel (Excel 2010 and later)

  1. First, run a CSV export with the desired profile in your Shopware shop.

  2. Open a new document in Excel.

  3. Import the CSV file by going to the Data tab and clicking Get Data → From Text.

  4. Select Delimited and choose Unicode (UTF-8) as the file origin, then click Next at the bottom.
    ​

  5. Select the semicolon as the delimiter.
    ​

  6. When editing the file, make sure to use the same decimal separator that you configured in the import/export tool. In Excel, you can set the decimal separator via the advanced options.

  7. The exported file can now be used as a template and filtered and edited accordingly.

  8. Save the edited file as a CSV file in UTF-8 format

  9. Finally, import the CSV file into your shop.

CSV import/export with LibreOffice Calc

  1. Open LibreOffice.

  2. Select the CSV file via Open File.

  3. Similar to Excel, a dialog opens where you need to make the settings described above.

  4. Confirm the settings with OK.
    ​

  5. You can use the exported file as a template and filter and edit it accordingly. Make sure to use the same decimal separator as in Shopware.

  6. Save the file as a CSV file in UTF-8 format. To do this, select Save As and tick the box next to Edit filter settings. Then click Use CSV format and select the UTF-8 format again in the dialog that appears.
    ​

What should I do if my spreadsheet program does not support UTF-8 encoding?

If your spreadsheet program does not support valid UTF-8 encoding, you can ensure UTF-8 encoding as follows: Open the edited CSV file in a text editor and save it there as a UTF-8-encoded CSV file. This detour via the editor allows the file to be saved correctly in UTF-8 format.

For the import into Shopware, the CSV file must be UTF-8 encoded. To be safe, test the import beforehand in a test environment or staging system. Before running the import in the live system, it is advisable to create a database backup first.

Turning stock management on or off via CSV

For many products, the fastest way to turn Manage stock on or off is via CSV import. To do this, add these two fields to your import profile for products:

  • pickwareErpPickwareProduct.id assigns the row to the correct product

  • pickwareErpPickwareProduct.isStockManagementDisabled controls stock management

Attention: isStockManagementDisabled is a negative value: true means that stock management is turned off.

If the error message … is set to required by the user but has no value appears during the import, remove the Required switch for the relevant field in the profile.

Imports run asynchronously. For the change to take effect, the message queue and the Pickware indexer must be able to run.

What should I do if an import fails?

You can see why an import failed on the import's detail page. For example, it says Es wurde kein Lager für diesen Lagerplatz angegeben if the Warehouse column is missing in the file. Also check these typical causes:

  • Column headers in a different language: The import expects column headers in German or English. If you exported the file with the Shopware Admin set to a different language, the re-import fails without a meaningful message. Set the language of the Admin to German or English and export the file again.

  • Required column missing: Columns such as Warehouse must be present in the file.

  • Incorrectly encoded column header: An incorrectly encoded umlaut in the column header, for example in Warehouse code, makes the column unreadable. Save the file in UTF-8 format, as described above.

  • Import stays on Scheduled: The Shopware message queue processes imports and exports. If they stay on Scheduled, the worker is not processing the queue. To find out how to check this, see What can I do if my message queue is not working?

Attention: Remove columns that you do not want to change from the file before the import. For example, if the Stock column is still in the file, the re-import overwrites all stock values that differ from the value in the file.

Did this answer your question?