Data Inheritance
A very important feature in connection with PIM is data inheritance. Data inheritance means, that objects of the same class can inherit data from their parent objects in the object tree.
One use case is the storage of product data. Imagine, you have a group of products which have many attributes in common and differ in just a few attributes (for example size, color, ...). So you can create a parent product which stores all the common attributes. Then you add child products and specify attributes in which the products differ (size, color, ...). All other attributes they inherit from the common parent product.
Data inheritance has to be enabled in the class definition like in the screen below:

If data inheritance is enabled and an attribute of an object is empty, pimcore tries to get this attribute from a parent object. This works only, if the parent object has the same class as the child object. Data inheritance between different classes is not supported.
In the pimcore admin, inherited values are visualized as in the screen below: they are gray and a bit transparent, and have a green marker in the upper left corner. With click on this corner, one can open the source object of this specific attribute (since 1.4.0).


To get the inherited values in the backend via code, you have to use the getter-methods of the attributes. By accessing the attributes directly, you will not get the inherited values.
| Bear in mind The complex data types field collections and translated fields do not support inheritance. |
Class Inheritance
Pimcore data objects support inheritance, just as any php object does. In pimcore the class from which a specific data class inherits can be changed. By default a data class inherits from Object_Concrete, but if required otherwise, a data class can extend a different parent class. If the parent class should be changed, this needs to be specified in the class definition as shown in the screen below:

| Be Careful This is a very advanced feature and should only be used by very experienced developers who know what they are doing and what consequences it might have when the parent class is changed from Object_Concrete to something else. In order to maintain all pimcore functionalities, it has to be ensured that the special class used in the example above extends Object_Concrete and that it's methods don't override and clash in unexpected ways with existing methods of Object_Concrete or any magic functions of Object_Concrete or it's parent classes. |
Hooks available when using class inheritance
Currently there's one hook available. Hooks can be defined as simple methods in the extended class.
| Method | Arguments | Description |
|---|---|---|
| preGetValue($key) | $key (the name of the property) | This method is called in the getter. This hook makes it possible to modify data before returning it to the caller. |
Example:
Please see the image above how to extend from a custom class.
class Website_Object_Special extends Object_Concrete { public function preGetValue($key) { if($key == "myCustomProperty") { return strtolower($object->myCustomProperty); } } }