Import Definitions


I have use “Import Definition” bundle to import csv and to create data-objects.

Now I need to put imported data-Object to relevant folders. I need to do it automatically.

eg -

  • Import fist row of the CSV
  • Check the CSV first row “Category” column value
  • According to column value need to move into relevant folder.

I have tried with “Runner” is it possible to do this using “Runner” or not?

I can see it’ll says to create service -

  • where I need to create this service?
  • Do I need to create new bundle?

I can see it says - “acme_bundle.import_definition.my_runner:

  • That mean “acme_bundle” is new bundle we need to create?
  • “import_definition” means “Import Definition” bundle location or?
  • And implementation of “RunnerInterface” where I need to place this class file?

Is there have any solution to this



to set the path of imported objects you can use Path field in import definition settings. There you can use placeholders to set path eg. to: /products/%Text(mycolumn1);/%Text(mycolumn2);
mycolumn1 and mycolumn2 are the names of the columns in csv. This will automatically create the folder also if it doesn’t already exist.
For more complicated structures not achievable by above directly I am using my own interpreter which returns correct folder (and creates it if it doesn’t exist). I then set it in Mappings in o_parent with Custom From column and my folder interpreter.
But as starter I think the first solution should work well for most cases.


BTW: If you don’t know what a service is, move a step back and start with the symfony documentation first:


Thank you very much… My csv it’s comes with category code not full name. I hope I need to do some mapping.

csv column category value is - OFH
my data-object folder name is Office & Furniture Hardware

I need to match those two and place into correct folder.

What is the best way to do this with “Import Definitions” code?



You somehow have to define how to map it. Either use object-properties or something else… You need to decide how to do the mapping


Ok, Thanks mertaivan and dpfaffenbauer

It is really help full your reply mertaivan according to that I have implement my solution and here I’m going to keep what I have been done. I think it’ll help to others to understand.

Fist install Import Definition -

(it’ll install into - /var/www/html/example2.loc/vendor/w-vision/import-definitions/src/ImportDefinitionsBundle/)

composer require w-vision/import-definitions:^2.0-dev

bin/console pimcore:bundle:enable ImportDefinitionsBundle

bin/console pimcore:bundle:install ImportDefinitionsBundle

Add new custom Interpreter

Add “categorymap.js” to

Add “CategoryMap.php” to

Add “CategoryMapInterpreterType.php” to

Update Service.yml in -

adding Following -

        class: ImportDefinitionsBundle\Interpreter\CategoryMap
            - { name: import_definition.interpreter, type: category_map, form-type: ImportDefinitionsBundle\Form\Type\Interpreter\CategoryMapInterpreterType }

Update config.yml in -

adding follwing -

interpreter_categorymap: '/bundles/importdefinitions/pimcore/js/interpreters/categorymap.js'

To import csv use following CLI command -

Run upload - bin/console import-definitions:import -d 1 -p "{\"file\":\"sap_export1.csv\"}"



NEVER work directly in the vendor folder! Once you install an update, everything is gone!

It works the same by adding all of those files into your AppBundle!


Thanks dpfaffenbauer,

it’s true I have move my code into new bundle and now there is no any code update in vendor folder.



I fail at adding a text field in a new formType for an interpreter.
Can anyone provide me with a good implementation of something like that? (in a bundle, not inside the w-vision/importdefinitions-bundle).


can you explain more what you are trying todo?


I want to implement a new interpreter, which (similar to the interpreter “expression”) has an additional inputfield of type text. I tried to “copy&paste” the definition of the ExpressionTypeForm and make the necessary changes, but I just don’t know what I have to rewrite…


Example of my interpreter (I call it Folder Interpreter):


 * Import Definitions.
 * This source file is subject to the GNU General Public License version 3 (GPLv3)
 * For the full copyright and license information, please view the and gpl-3.0.txt
 * files that are distributed with this source code.
 * @copyright  Copyright (c) 2016-2018 w-vision AG (
 * @license GNU General Public License version 3 (GPLv3)

namespace AppBundle\ImportDefinitions;

use ImportDefinitionsBundle\Interpreter\InterpreterInterface;
use ImportDefinitionsBundle\Model\DefinitionInterface;
use ImportDefinitionsBundle\Model\Mapping;
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\DataObject\Service;
use Pimcore\Model\DataObject\Folder;

class FolderInterpreter implements InterpreterInterface
     * {@inheritdoc}
    public function interpret(
        Concrete $object,
        Mapping $map,
        DefinitionInterface $definition,
    ) {
        if($rootPath=="") $rootPath=$definition->getObjectPath();        
        $path=eval('return '.$configuration['field'].";");        
        return $folder;



pimcore.plugin.importdefinitions_interpreters_folder = Class.create(pimcore.plugin.admin, {
    getClassName: function() {
        return "pimcore.plugin.importdefinitions_interpreters_folder";

    initialize: function() {;
    pimcoreReady: function (params,broker){
        pimcore.plugin.importdefinitions.interpreters.folder = Class.create(pimcore.plugin.importdefinitions.interpreters.abstract, {
            getLayout : function (fromColumn, toColumn, record, config) {
                var classesStore = new{
                    autoDestroy: true,
                    proxy: {
                        type: 'ajax',
                        url: '/admin/class/get-tree'
                    fields: ['text']

                return [{
                        xtype : 'textarea',
                        fieldLabel: t('importdefinitions_interpreter_folder_field'),
                        name: 'field',
                        width: 500,
                        value : config.field ? config.field : null

var importdefinitions_interpreters_folderPlugin = new pimcore.plugin.importdefinitions_interpreters_folder();


 * Import Definitions.
 * This source file is subject to the GNU General Public License version 3 (GPLv3)
 * For the full copyright and license information, please view the and gpl-3.0.txt
 * files that are distributed with this source code.
 * @copyright  Copyright (c) 2016-2018 w-vision AG (
 * @license GNU General Public License version 3 (GPLv3)

namespace AppBundle\Form\Type\Interpreter;

use ImportDefinitionsBundle\Form\Type\ClassChoiceType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

class FolderInterpreterType extends AbstractType
     * {@inheritdoc}
    public function buildForm(FormBuilderInterface $builder, array $options)
            ->add('field', TextType::class);

     * {@inheritdoc}
    public function getBlockPrefix()
        return 'import_definitions_interpreter_folder';


            folder: '/bundles/app/js/folder.js'


        class: AppBundle\ImportDefinitions\FolderInterpreter
            - { name: import_definition.interpreter, type: folder, form-type: AppBundle\Form\Type\Interpreter\FolderInterpreterType }

Of course, the folder structure might be different and maybe better but this should give you a hint.