Logo BrocksiNet

BrocksiNet

Try to clean the web

Import / Export Customers via CSV in Shopware 6

At some point in every project you need some customer data. And often it is the case that you need to import the customer data from some old source for example from WooCommerce. In this case you can use the csv import/export feature from Shopware 6 core. So this post is a small how to import/export customer data and create a profile for your needs in Shopware 6 admin.

What we will do?

  • Create a customer via administration
  • Create a customer profile with data mapping
  • Export existing customers via administration
  • Change the exported csv file
  • Import the changed csv file to import/create new customers

Create a customer via administration

This step is only needed when you do not have any customer data in your system.

  • Login to the Shopware 6 Administration
  • Navigate to: Customers > Overview
  • Click on the button: Add customer
  • Fill out all the required fields
  • Save the customer

Create a customer profile with data mapping

  • Navigate to: Settings > Import/Export
  • When you on the Import/Export page click on Profiles in the the tab menu
  • Click on Add new profile (make sure you are on the default language english)
  • Put in Customer as profile name
  • Select as Object type Customer
  • Add the mappings from CSV columns to Shopware 6 data/fields
    (see example mapping below, 32 fields)
  • Click on the Save profile button

Example Mapping: CSV Column Names to mapped Shopware 6 Customer Fields/Data

ID, id
billing_address_1, defaultBillingAddress.street
billing_address_2, defaultBillingAddress.additionalAddressLine1
billing_city, defaultBillingAddress.city
billing_company, company
billing_country, defaultBillingAddress.countryId
billing_first_name, defaultBillingAddress.firstName
billing_id, defaultBillingAddressId
billing_last_name, defaultBillingAddress.lastName
billing_phone, defaultBillingAddress.phoneNumber
billing_postcode, defaultBillingAddress.zipcode
billing_salutation_id, defaultBillingAddress.salutationId
customer_id, customerNumber
default_payment, defaultPaymentMethodId
first_name, firstName
language_id, languageId
last_name, lastName
roles, groupId
saleschannel_id, salesChannelId
salutation_id, salutationId
shipping_address_1, defaultShippingAddress.street
shipping_address_2, defaultShippingAddress.additionalAddressLine1
shipping_city, defaultShippingAddress.city
shipping_company, defaultShippingAddress.company
shipping_first_name, defaultShippingAddress.firstName
shipping_id, defaultShippingAddressId
shipping_last_name, defaultShippingAddress.lastName
shipping_postcode, defaultShippingAddress.zipcode
shipping_salutation_id, defaultShippingAddress.salutationId
shipping_country, defaultShippingAddress.countryId
user_email, email
user_pass, password
user_registered, createdAt

Export existing customers via administration

  • Navigate to: Settings > Import/Export
  • When you on the Import/Export page click on Export in the the tab menu
  • Select the profile with the name Customer
  • Click on the Start export button

Change the exported csv file

If you want to create new customers, with this import, then these fields have to be empty: id, defaultBillingAddressId and defaultShippingAddressId. Look for the corrosponding csv column and make sure they are empty. If you want to update customers these fields should be untouched and should be matching the UUID of the current Shopware 6 system.

Also you need to provide a customerNumber but this number can just be ongoing, it is just a string.

Replace the exported columns with your customer data from the others source. Make sure you set salutationId and countryId correct. You can find this Ids via Administration. Or you use the Ids from some exported customers. Be careful, if you do something wrong you maybe end up with wrong customer data in your system.

Import the changed csv file to import/create new customers

  • Navigate to: Settings > Import/Export
  • After the new page was loaded you are already on the Import tab
  • Click on Choose file and then select the changed csv file (you wanna use for the import)
  • Select the profile with the name Customer
  • Click Start import and when you get the green message 🥳

Frequent problems

Here we collect the most frequent problems we faced during import/export customer data in Shopware 6.

Where to find the logs when an import was not working?

You should download the csv file for the not imported entries.
If you scroll to the end of the file, you will see the error logs attached in a own column.

Download the csv file that could not be imported to see the errors.At the end of the csv file you find a column with all errors.

The import/export profile was saved without a name?

Change to the default language before you save the profile. This should be english.

If you wanna change the name in your current language (for example german), then first save it in english, then change to german, rename the profile and save it again.

There where no errors but also nothing was imported?

This is often the case when the csv separators and/or the enclosure characters do not match. Check in profile and in csv file if they are the same. Default is semicolon (;) and Double quotes ("). Also check that your csv file is supporting UTF-8.

Additional Resources

Released - 10.01.2022

Bild Bjoern
Björn MeyerSoftware Engineer
Björn is interested in the details of web technologies. He started with Joomla, Drupal, Typo3, vBulletin, Fireworks and Photoshop. Today his focus is on PHP for example with Magento 2, Shopware 6 and Symfony. He also likes JavaScript with Angular, React, VueJs and TypeScript. In his free time, he seeks constant balance with swimming, running and yoga.