Repository: pimcore/pimcore (language: php)

Issue:
[Bug]: child is not inherting the parent object many-to-one relation field
### Pimcore version

11

### Steps to reproduce

create one class which includes the many-to-one relation; and make class as inhirtable

create parent object add the relation field and save
 and try to create child object for above parent 


### Actual Behavior

child is not inheriting the parent objects many-to-one  relation field
it is saving as null for field_id and type field in object_query_table
![image](https://github.com/pimcore/pimcore/assets/85212799/c1b8b498-330c-4b9b-b81c-31982260a1cd)
i have checked in the demo same issue is reproducable
after debugging i found issue
is in vendor/pimcore/pimcore/models/DataObject/ClassDefinition/Data/ManyToOneRelation.php
getDataForQueryResource method which is returning null instead of array with keys and empty value to Dao for saving parents data in child
![image](https://github.com/pimcore/pimcore/assets/85212799/7ec13498-d293-4304-a3e6-7621be20d11d)

it will work fine if i make changes like below
![image](https://github.com/pimcore/pimcore/assets/85212799/802228fc-be7c-4a5c-afd0-5ad774fcd31b)




### Expected Behavior

child should inherit the parents relation type
and in db object_query_classId the field of reation should save
[Bug]: child is not inherting the parent object many-to-one relation field
### Pimcore version

11

### Steps to reproduce

create one class which includes the many-to-one relation; and make class as inhirtable

create parent object add the relation field and save
 and try to create child object for above parent 


### Actual Behavior

child is not inheriting the parent objects many-to-one  relation field
it is saving as null for field_id and type field in object_query_table
![image](https://github.com/pimcore/pimcore/assets/85212799/c1b8b498-330c-4b9b-b81c-31982260a1cd)
i have checked in the demo same issue is reproducable
after debugging i found issue
is in vendor/pimcore/pimcore/models/DataObject/ClassDefinition/Data/ManyToOneRelation.php
getDataForQueryResource method which is returning null instead of array with keys and empty value to Dao for saving parents data in child
![image](https://github.com/pimcore/pimcore/assets/85212799/7ec13498-d293-4304-a3e6-7621be20d11d)

it will work fine if i make changes like below
![image](https://github.com/pimcore/pimcore/assets/85212799/802228fc-be7c-4a5c-afd0-5ad774fcd31b)




### Expected Behavior

child should inherit the parents relation type
and in db object_query_classId the field of reation should save


Discussion / hints:
@dvesh3  any updates about this??
@dvesh3  any updates about this??

Fix patch:
diff --git a/models/DataObject/ClassDefinition/Data/ManyToOneRelation.php b/models/DataObject/ClassDefinition/Data/ManyToOneRelation.php
index b0f9a938d3b..58a400cf2f2 100644
--- a/models/DataObject/ClassDefinition/Data/ManyToOneRelation.php
+++ b/models/DataObject/ClassDefinition/Data/ManyToOneRelation.php
@@ -207,13 +207,18 @@ protected function loadData(array $data, Localizedfield|AbstractData|\Pimcore\Mo
      */
     public function getDataForQueryResource(mixed $data, DataObject\Concrete $object = null, array $params = []): array
     {
-        $return = [];
+        $idIndex = $this->getName() . '__id';
+        $typeIndex = $this->getName() . '__type';
+
+        $return = [$idIndex => null, $typeIndex => null];
 
         if ($data != null) {
             $rData = $this->prepareDataForPersistence($data, $object, $params);
 
-            $return[$this->getName() . '__id'] = isset($rData[0]['dest_id']) ? $rData[0]['dest_id'] : null;
-            $return[$this->getName() . '__type'] = isset($rData[0]['type']) ? $rData[0]['type'] : null;
+            $return = [
+                $idIndex => $rData[0]['dest_id'] ?? null,
+                $typeIndex => $rData[0]['type'] ?? null
+            ];
         }
 
         return $return;


Test patch: