How to export and import data objects in Pimcore

What you’ll learn with this guide

This guide will show you how to migrate Pimcore data objects from one server to another using Pimcore's built.in CSV export/import functionality.

Where to use

Let’s say that during development you created a new class Car and you added a couple of objects of that class on your local machine. Now you want to create those objects on a live server too and the simplest way to do this is to use CSV export/import functionality. 

Solution

1) Export objects

To export objects, click on a folder or an object that contains all the objects you want to export as children (meaning that they are under the folder/object). If you clicked on the folder go to the “Search, Edit and Export” tab, and if you clicked on the object, go to the “Children Grid” tab. There you’ll see a table that contains data about the objects you want to export.

Search, edit and export in Pimcore

Now you can select which data you want to export by clicking on the “Grid Options” button in the top right corner. A popup will appear that will allow you to specify which fields from the Car class you want to export. On the left side, you can see all available fields, and on the right all currently selected fields. Fields can be added by double-clicking on them or by drag and dropping them in the right table.

Make sure that you selected either ID or Full Path fields because we will need them later while importing.

Grid options in Pimcore administration

When you select everything you want click on the “CSV Export” button in the top right corner and just select the delimiter for csv (by default its ‘;’) and your export will be done.

2) Import objects

When you want to import objects, right-click on “Home” in the DataObject tree and go to “CSV Import” and select for which class you want to import objects.

CSV import in Pimcore

It will ask you to upload a CSV file that contains import data. Once the file was selected, a new screen will appear and you’ll have to adjust a couple of settings before importing. 

Adjusting the settings for import in Pimcore

TIP: If you are importing relations, make sure that those related objects exist in the same path that's defined in CSV, in the system in which you are importing. Otherwise, those fields will be empty.

Go to the “Column Configuration” tab. There you must connect fields from the CSV file with fields in the class you are importing. On the left, you can see the fields in the Car class, and on the right, you can see the fields in the CSV file. Now you have to connect those by dragging and dropping the class field on the corresponding CSV field.

If you have special fields in the class like localized fields, you’ll have to use operators that can be found in the bottom left corner. For example, field Name is a localized field and because of that, we have to use Operator Locale Switcher to define for which language we want to import data (check the image below). 

Using operator locale switcher in Pimcore

Once you are done with column configuration switch to “Resolver Settings” tab. Here you’ll need to tell Pimcore how to create/update your objects. Most important options here are:

  1. Language - define for which language you want to import data (if this is defined you don’t have to use operator locale switcher in column configuration)
  2. Resolver strategy - this tells Pimcore how to create or find if an object already exists. We will use “Full Path” strategy
  3. Column - which csv column should be used for resolver strategy, here we will select the column that contains full path for our objects
  4. Create on demand - we need to check this so if objects don't exist they will be created
  5. Create parent - check this too, it will create parent folders for our objects if those folder doesn't exist 

Other options you can leave as default.

Resolver settings in Pimcore

Once everything is defined we can click “Import” in the bottom right corner, and if everything is defined correctly, the import will start and create/update objects.

Does it work? 

If you followed this tutorial closely you should be able to see imported data objects in the data object tree. If not, try with all the steps :) 

If you'd like some help with Pimcore, feel free to say [email protected]!

Looking for Exponential Growth? Let’s Get Started.
Explore next

Pimcore Tutorial

Check out our step-by-step tutorials on how to use Pimcore features and solutions.

Discover more