Create DataObject definition programatically


Hi, I’m new to the platform and I’m trying to create a module that will have a pre-defined DataObject definition built in, so every time I install that module into other projects that DataObject will be accessible in the backend.

I tried to find an way of doing this in the docs and also researching a little but couldn’t find anything, is this actually possible without any core customisation?

Also, I’ve seen that it is possible to create a custom persistence entity, but is it possible to make that entity available as a DataObject class in the backend? I’ve seen that CoreShop does that, but it is complex and apparently it’s overwritten some core functionality in order to do it.



Hi @gabrieldagama

You can export your classes in Pimcore to a json file and then import them again in the installation process of you bundle. Here you can see another example how that works:



Hi @scrummer, thanks for your reply! Yeah I guess that would help.



Hi @scrummer looking a little bit more there, in this case we would still have to create the class manually in the platform, right? I’ve seen that if there is no ID for that class the function returns false.

So we can export the definitions but there are still manual work required to create the class in the backend, right?



this is what you need:

Just pass in the class name and the JSON Definition and done. Pimcore does the rest for you.

BTW: You can use that in your Project by requiring the coreshop/pimcore package



Cool, yeah that is what I need :slight_smile:

Thanks for that @dpfaffenbauer! I guess the most important part is this method


Thanks for that!