Search code examples
javabackendsap-commerce-cloud

Hybris Item: difference between custom-property and attributes


In the definition of a hybris type I've come across difficulty with understanding the meaning of this two tags: <custom-properties> and <attributes>

In detail, the first contains child tags <property> and the second contains child tags <attribute>. In the "property" tags there is a further tag <value> with content.

The example code on which I am based is taken from the hybris trail, that is:

<itemtype
    code="News"
    autocreate="false"
    generate="false">
    <custom-properties>
        <property name="catalogItemType"><value>java.lang.Boolean.TRUE</value></property>
        <property name="catalogVersionAttributeQualifier"><value>"catalogVersion"</value></property>
        <property name="uniqueKeyAttributeQualifier"><value>"id"</value></property>
    </custom-properties>
    <attributes>
        <attribute qualifier="id" type="java.lang.String">
            <modifiers initial="true" optional="false" write="true"/>
            <persistence type="property"/>
            </attribute>
        <attribute qualifier="catalogVersion" type="CatalogVersion">
            <modifiers initial="true" optional="false" write="true"/>
            <persistence type="property"/>
        </attribute>
    </attributes>
</itemtype>

Overall, what is the difference between the two tags <custom-properties> and <attributes>?


Solution

  • <custom-properties>
        <property name="catalogItemType">
            <value>java.lang.Boolean.TRUE</value>
        </property>
        <property name="catalogVersionAttributeQualifier">
            <value>"catalogVersion"</value>
        </property>
        <property name="uniqueKeyAttributeQualifier">
            <value>"code"</value>
        </property>
    </custom-properties>
    

    These <custom-properties> are used to define ItemType as catalog aware. Like Product Type. You can refer this post for more detail.

    <attribute> is used to define and configure a column of the table/item.

    In SQL word, I can say <custom-properties> is used for table level configuration(metadata) and <attribute> is used to define and configure the column of that table.