Relation between DataObject and custom persistent model


#1

How can I define realations between DataObjects and custom persistent model (doctrine ORM)?

I have a DataObject called “rentalUnit” an a custom persistent model called “prices”. Each rentalUnit can have
one price. How can I tell rentalUnit that there is one price relation? The relation should be set programmatically.

THX


#2

Hi,

CoreShop does this everywhere, you could have a look at it. Especially the ResourceBundle adds a lot for that stuff: https://github.com/coreshop/ResourceBundle. Also the other way around works with CoreShop, having a relation between a Doctrine Entity and CoreShop like here: https://github.com/coreshop/CoreShop/blob/master/src/CoreShop/Bundle/CoreBundle/Resources/config/doctrine/model/Payment.orm.yml#L6


#3

Thank you. Are there any docs on doing this? It’s not easy to understand such a complex example like CoreShop :flushed:.


#4

Basically all you need to do is create a custom object-tag like https://github.com/coreshop/CoreShop/blob/master/src/CoreShop/Bundle/ResourceBundle/CoreExtension/Select.php or use ResourceBundle and create Doctrine entities the way CoreShop does, that way it generates factories, repositories and other stuff automatically for you.


#5

Like this in the docs - https://pimcore.com/docs/5.x/Development_Documentation/Extending_Pimcore/Bundle_Developers_Guide/Adding_Object_Datatypes.html?


#6

yes, exactly. CoreShop would already add an abstract for that, so you only would need to extend from it and overwrite certain functions.


#7

Are there any docs on how to build up the JavaScript classes? The Link “For examples have a look at the Pimcore core datatypes at github” in pimcore doc is nice but at the moment I can’t understand the relations between all the different files.


#8

you need to create 2 js files, data and tag. CoreShop has a base class to do that:

Tag:
Tag is for the actual editable

Data:
Data is for the class editor

Concrete implementation for a entity:

Tag:

Data: