venkat ch
venkat ch

Reputation: 63

Hybris data modeling : custom properties

I am trying to understand custom properties in hybris data modeling; Could anyone share useful links or information about it?

Upvotes: 1

Views: 3641

Answers (3)

Amirtha Rajan
Amirtha Rajan

Reputation: 635

Item attributes define the state of an item. They are actually the columns of the the db table that is created (except the dynamic attributes) as a result of platform build and update process.

Custom attributes are certain defined attributes which are used in the type system definition to defined certain properties of a type. In general, if you interpret the metadata of the type system you may read the attributes to achieve the desired behaviour. They could be defined at various levels

  1. At an item type level - Custom-properties are used to define properties for a type. For example

<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>

these properties are defined at a type level - These attributes provide catalog awareness at a type level. These attributes could be retrieved these item type properties at runtime via the getProperty( String propertyName ) methodThere are other examples as well.

  1. Relation level, please see the snippet below

<relation code="User2Addresses" generate="true" localized="false" autocreate="true">
    <sourceElement type="User" cardinality="one" qualifier="owner">
        <modifiers read="true" write="true" search="true" optional="true" initial="false"/>
    </sourceElement>
    <targetElement type="Address" cardinality="many" qualifier="addresses">
        <modifiers read="true" write="true" search="true" optional="true" partof="true"/>
        <custom-properties>
            <property name="condition.query">
                <value>"{original} is null"</value>
            </property>
        </custom-properties>
    </targetElement>
</relation>

The property holds a string that is later added to the 'where' part of the select query generated for a one-to-many or many-to-one relation.

  1. Ordering Attribute - By defining ordering.attribute, it is possible to specify which attribute will be used to order the many-side items when retrieving from the database

<relation code="AbstractOrder2AbstractOrderEntry" localized="false" generate="true" autocreate="true">
	<sourceElement type="AbstractOrder" qualifier="order" cardinality="one">
		<modifiers read="true" write="true" search="true" optional="true" />
				<custom-properties>
					<property name="ordering.attribute">
						<value>"entryNumber"</value>
					</property>
				</custom-properties>
			</sourceElement>
<targetElement type="AbstractOrderEntry" qualifier="entries" cardinality="many" collectiontype="list" ordered="false" >
		<modifiers read="true" write="true" search="true" optional="true" partof="true" />
</targetElement>
		</relation>

  1. Backoffice Custom Attributes- Backoffice would allow to display all attributes of any type (out of the box), nevertheless there are some special (let's say technical) attributes that definitely should not be visible in the UI or should at least be readonly in the UI (no matter what the access rights they have). For those very rare case hybris have introduced two custom attributes that we interprete when the typesystem is scanned

    <property name="readOnlyForUI">
       <value>Boolean.TRUE</value>
    </property>
    <property name="hiddenForUI">
       <value>Boolean.TRUE</value>
    </property>

Hope this helps!

Upvotes: 3

HybrisHelp
HybrisHelp

Reputation: 5810

I hope you want to know about

<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.


Refer helphybris post for more detail

Upvotes: 0

zslb
zslb

Reputation: 301

Have a look at The Type System in Hybris Help, as well as Data Models in the Hybris123 section.

Models are defined per extension in extensionname-items.xml, and generated during the build process.

In order for model updates to be reflected in the type system of your instance, run a system update in HAC > Platform > Update. For more information, see also Initializing and Updating SAP Hybris Commerce.

Upvotes: -1

Related Questions