I have created a new type of dataobject foo in Pimcore admin contains 2 localized fields title & text. There are 100 of dataobjects created within it. But thing is to setup parent-child relationships between them. Some are Parents, some children and some are at 3rd level. I want to fetch them with relationship that will help me display in proper way.
I have an approach that will included a new field parentId and store object's parentId in that to mmanage relations. But that's not effective while displaying the content.
How can I setup relationship in better way?
One way of solving this is to put Data Objects in desired hierarchy already in the tree. So when you add new child object, you just add it under the parent object in the tree and then in front-end, when you have parent instance you just call
$parent->getChildren()and you can loop trough it (same for 3rd level).In case one child can have multiple parents, this won't work though - in this case you have to use one of the relation types.