on 2018 Nov 04 12:07 AM
What is the role of metatype in the following code?
<relation code="CategoryProductRelation" autocreate="true" generate="true" localized="false">
<sourceElement qualifier="supercategories" type="Category" cardinality="many" metatype="Product">
<modifiers read="true" write="true" search="true" optional="true" removable="true" initial="false" unique="false" private="false" partof="false"/>
<deployment table="cat2prodrel" typecode="143"/>
</sourceElement>
<targetElement qualifier="products" type="Product" cardinality="many" metatype="Category">
<modifiers read="true" write="true" search="true" optional="true" removable="true" initial="false" unique="false" private="false" partof="false"/>
</targetElement>
</relation>
The documentation at https://help.hybris.com/1808/hcd/8bff7a568669101488a5e40cb7bbd0b9.html defines it as "The (meta)type which describes the attributes type. Must be type extending RelationDescriptor. Default is 'RelationDescriptor'." which gives rise to another confusion.
The hierarchy of RelationDescriptor is
RelationDescriptor->AttributeDescriptor->Descriptor->TypeManagerManaged->LocalizableItem->ExtensibleItem->Item
whereas that of Product is
Product->GenericItem->LocalizableItem->ExtensibleItem->Item
So, Product does not extend RelationDescriptor.
The definition of metatype is at other places as well in this document but they are applicable to itemtype and attribute.
I never came across any scenario when I had to use it either for sourceElement or for targetElement. But I hope someone who has used it while defining a custom relation must be aware of its purpose and will be able to clarify its usage in the CategoryProductRelation mentioned above.
Request clarification before answering.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.