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.





Author Image

Ankitkumar Patel

Sr. SAP Hybris consultant, having 6+ years experience in Hybris, Java, J2EE. Extensive hands-on experience in SAP Hybris development, third-party integrations with Hybris, project architecture and design... Read more

Comments

Popular posts from this blog

Hybris flexible search query examples

How to remove or update all data records in Hybris?

Hybris backoffice customization