ImportDefinitions plugin - import hierarchy of objects

I have simply CSV with names:
Category and Subcategory are objects class A
Product is object class B

I define Import of CSV Provider and Class B. Is it possible (using only existing interpreters and setters) import and create objects of category and subcategory (class A) in the same import, then set product as child of subcategory object?
I assume I don’t know the parent ID before I create the category tree.

If anyone has experience with similar problem, I will be grateful for advice. :slightly_smiling_face:

Actually yes, you can call sub-definitions.

You have todo following:

  • Create a new definition called category and select class A with provider raw
  • In the settings you define the same schema as you have in your parent definition
  • Go back to your product definition
  • Create a new mapping for the categories field. I assume it is a multihref
  • Use interpreter nested
  • Add a new one
  • Use expression with the config [data['category'], data['subcategory']]
  • Add a new one to nested
  • Use definition
  • Choose your category definition.

You also have to create the sub-category in your category definition in a similar way, I hope you get the idea. It is a bit confusing and also complicated.

Thanks for your help Dominik! It works good.
I used mapping for the (sub)category in field o_parent and in this way Pimcore created tree of objects.

Hi Dominik,

I have a task similar to the one described by the opener of this task.
I followed your instructions about how to import products and categories as different classes; import was successfull, thanks!

There is one last thing I’d like to accomplish: I’d like to customize the product path in order to show the different category levels, so that object are organized in a tree-like folder structure (e.g. /category1/category2/productName)

How do I change the “path” field in the import definition settings in order to accomplish this?

Thank you,

You need to create an interpreter that creates the hierarchy, use the interpreter in the field o_parent within the mapping

1 Like