How to create catalog aware ItemType in Hybris?
Scenario
Create an Item type which can have two versions(stage/online) like the product type. In simple word, it should be catalog aware.
Solution
We can declare any Item type as catalog aware using in *-items.xml
<itemtype code="MyConfiguratorSetting" extends="GenericItem" autocreate="true" generate="true">
<deployment table="ConfiguratorSettings" typecode="1301" />
<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>
<attributes>
<attribute qualifier="code" type="java.lang.String">
<description>Identifier</description>
<persistence type="property"/>
<modifiers read="true" write="true" search="true" optional="false" unique="true"/>
</attribute>
<attribute qualifier="catalogVersion" type="CatalogVersion">
<description>Catalog Version</description>
<modifiers optional="false" write="false" initial="true"/>
<persistence type="property"/>
</attribute>
<attribute qualifier="configValue" type="java.lang.String">
<description>configValue</description>
<persistence type="property"/>
<modifiers optional="false" write="false" initial="true" />
</attribute>
</attributes>
</itemtype>
Use of <custom-properties>
catalogItemType - To declare current itemType is catalogItemType
catalogVersionAttributeQualifier - An attribute from our itemType, which will qualify the catalog. In our case it's catalogVersion.
uniqueKeyAttributeQualifier - An attribute from our itemType, which can define each record/instance as unique. In our case it's "code". But it also can be a combination of multiple fields.
Comments
Post a Comment