You are on page 1of 11

Defining a new item type is so simple in

Starting on Hybris platform as a beginner thought that defining an item type in
Hybris so simple by adding its entry in –items.xml file. Yes this is true; In Hybris all
the type definitions are defined in –items.xml file under the custom extension.
Hybris will create corresponding table definitions, column types and relationships in
the underlying data base leaving the developer to only concentrate on business
After having a good amount of experience on Hybris platform now considering
above statement is not 100% true. Considering the HMC (Hybris Management
Console) and Product cockpit it is not enough to add the type definition into –
items.xml file. There are so many files that we need to write in order to make a
type available completely useable in the hybris system.
Let’s explore what would be required to create a new item type (ProductWarranty)
definition in Hybris

All the new type definitions in the hybris system are defined in items.xml file.
This file is used to structure the database objects for the hybris service layer.
<itemtype code="ProductWarranty" extends="GenericItem"
autocreate="true" generate="true">
<deployment table="Warranties" typecode="12143" />
<attribute qualifier="code" type="java.lang.String">
<modifiers optional="false" read="true" write="true"

Boolean.xml file.Boolean"> <description>GLN</description> <modifiers optional="true" read="true" write="true" search="true" /> <defaultvalue>java. <type name="ProductWarranty" mode="append"> <organizer> <search mode="replace"> <condition attribute="code"></condition> <condition attribute="active"></condition> <condition attribute="catalogVersion"></condition> </search> <result defaultview="list" mode="replace"> <listview > <itemlayout> <attribute name="code" . This type is defined as catalog aware.lang.lang.TRUE</defaultvalue> <persistence type="property" /> </attribute> <attribute qualifier="catalogVersion" type="CatalogVersion"> <modifiers initial="true" optional="false" write="false"/> <persistence type="property"/> </attribute> </attributes> </itemtype> The above ProductWarranty type definition is created with code as a unique primary key.unique="true" search="true" /> <persistence type="property" /> </attribute> <attribute qualifier="active" type="java. HMC Configuration: In order to use above type in Hybris HMC we need to add a type definition into hmc.

xml) its add some extra information to the item type layouts in HMC (We will see that in next sections. When you specify mode as append for a new item type definition (if you are defining this new item type for the first time in hmc.details"> <listlayout> <attribute name="code" width="200"></attribute> <attribute name="active" ></attribute> <attribute name="catalogVersion" width="200"> </attribute> </listlayout> </section> </tab> </editor> </organizer> <defaultreference searchattribute="code" mode="replace"> <itemlayout> <attribute name="code"/> </itemlayout> </defaultreference> </type> Let’s go over line by line from the above definition <type name="ProductWarranty" mode="append"> Above type definition notifies hybris system that we are making a new item type available into hybris and the type name is ProductWarranty Mode can be one of 'append'. 'replace' or 'delete'.width="200"></attribute> <attribute name="active" ></attribute> <attribute name="catalogVersion" width="200"> </attribute> </itemlayout> </listview> </result> <editor> <tab name="tab.details"> <section name="section. <organizer> .warranty. Default is 'append'.warranty.

. active and catalog conditions.<search></search> <result></result> <editor> </editor> </organizer> Organizer contains descriptions on how the different organizer components represent this type. Now let’s see all these sections in HMC Now above screen in hmc will allow searching for a product warranty based on warranty. Search section will define the search attributes for this type Result will define the how the results will be displayed Editor will define the tabs and sections of this type <defaultreference> Describes how items of this type look (by default) when they are referenced in a different location.

xsd file on where to mention this entry) Explorertree design the layout of the left navigation. Labels for the Product Warranty. Now all the sections for the product warranty have been configured in hmc. Let’s see how to add this access point for this page. The question is now how to come to this page? To add an access point for this From the results after selecting a warranty editor section will display with the tabs and sections which are configured in the editor section of organizer tag in hmc.xml file (refer"/> </group> </explorertree> Above definition need to be added to hmc. <explorertree> <group name="sbdgroup"> <typeref type="ProductWarranty" description="tree. edit and tree modes by default list (For more information on these modes refer wiki. section and explorertree definitions we used keys for labels. In the hmc. Result section can be configured in list. We need to add this product warranty to one of the customized folder or existing folder from the left navigation.xml. There is one last configuration is still pending.hybris.The search results will be displayed in result section after the search. Hybris will add this tab by default for every new item type defined in hmc. A folder with SBD is created and a reference link for the product warranty has been created Now all the configuration for the Product Warranty in HMC is established. But where these keys and its values would be defined? .ProductWarranty.xml for tab.xml Though Administration tab was not added to the definition. type> All the hmc specific labels / localizations are defined locales_en.details= Warranty Details section. But configuring the product information in not enough in product cockpit.g ProductWarranty).code.<code type. All the product related information can be maintained in product Product cockpit configurations Default product cockpit is configured to manage the OOTB and custom products.<code of of of of type> Active type.details= Warranty Information tree. All the product related attributes (automic or composed types) would require separate xml configurations ( type> Warranty This completes the HMC Version locales_en.ProductWarranty.description=XY type>.name= Product Warranty type.<code type.ProductWarranty.<code type.warranty.<qualifier of attribute>.properties file Sbdgroup = SBD tab.<qualifier of attribute>.description=XY type. <collectiontype elementtype="ProductWarranty" code="ProductWarrantyCollection" autocreate="true" /> . Before looking into ProductWarranty let’s see how product warranty is related to All the localization parameters are defined into this properties file and in Hybris there is a predefined structure to add labels for item types # # # # # # syntax for type localizations: type. There are various xml configurations are required for making product useful. For more information please look at wiki.ProductWarranty.

active" /> <property qualifier="Item. base_ProductWarranty. Extends Product </description> <attributes> <attribute type="ProductWarrantyCollection" qualifier= "warranties"> <persistence type="property"></persistence> <modifiers read="true" search="true" optional="true" write="true" dontOptimize="true"></modifiers> <description>List of warranties for the product</description> </attribute> </attributes> </itemtype> We will not discuss much on the above product definitions.0" encoding="UTF-8"?> <base> <search> <search-properties> <property qualifier="ProductWarranty.code" /> <property qualifier="ProductWarranty.code" /> <property qualifier="ProductWarranty.catalogVersion" /> <property qualifier="ProductWarranty. Let’s see how to configure the Product Warranty xml configurations for product cockpit.catalogVersion" /> </search-properties> <sort-properties> <property qualifier="ProductWarranty.----------------------------------------------------------------------------------------<itemtype code="SBDProduct" extends="Product" autocreate="true" generate="true"> <description>Product implementation in SBD.xml <?xml version=""/> </sort-properties> </search> <label spring-bean="sbdProductWarrantyLabelProvider"/> .

String.</base> Base configuration defines base search and sort properties and also product warranty label used wherever product warranty is selected. By default the first attribute which is defined under sort properties is considered for sorting. Hybris understands the automic attributes (e. Collection etc) All the Label definitions in cockpit need to be extend AbstractObjectLabelProvider class (Refer wiki for more information) advancedSearch_ProductWarranty. Labels are used when a product warranty is selected for a product. Since ProductWarranty is a composed type Hybris doesn’t understand how to render the attribute. Sort configuration defines which fields are considering for the sorting. Search configuration defines on which fields are being considered for a general search in product cockpit. All the custom types has to use Hybris advanced search schema definition .g.xml Hybris provides a configuration file for advanced search on the product cockpit. Any text entered in base search field (refer wiki) will be carried search on code and catalogVersion is considered based on the user catalog access for the ProductWarranty. If not used warranty primary key will be displayed.

general.xml editor area defines the layout in product cockpit for creation and updating of ProductWarranty type.0" encoding="UTF-8"?> <advanced-search> <group name="root" type="ProductWarranty"> <label key="config. For grid view below is the configuration . gridview_ProductWarranty.xml Product cockpit provides two layouts grid and list views for search" /> </group> </advanced-search> editorArea_ProductWarranty.searchfor" /> <property qualifier="ProductWarranty.catalogVersion" /> <property qualifier="ProductWarranty.<?xml version="1.code" /> <property qualifier="ProductWarranty.

catalogVersion" visible="true" editable="false"/> <property qualifier="ProductWarranty.0" encoding="UTF-8"?> <list-view unassigned-group-name="Other"> <group name="General"> <property qualifier="" /> </descriptionslot> </grid-view> listviewContentBrowser_ProductWarranty. .0" encoding="UTF-8"?> <grid-view> <labelslot> <property qualifier="ProductWarranty.xml List ivew selector configuration will be used to display the search results when a product warranty type is selected from the reference" visible="true" editable="false"/> </group> </list-view>" /> </labelslot> <descriptionslot> <property qualifier="ProductWarranty.xml For list view on the product cockpit browser area below definition being used to display the search results .code" visible="true" editable="false"/> <property qualifier="ProductWarranty. <?xml version="1.<?xml version="1.

Wizard configuration defines how the product warranty field would be configured in the cockpits. ( More info refer wiki) <?xml version="1.catalogVersion"/> </group> </displayed-properties> </wizard-config> .General" /> <property qualifier="ProductWarranty.xml This is the final file for the type" /> <property qualifier="ProductWarranty.label.wizardConfig_ProductWarranty.0" encoding="UTF-8"?> <wizard-config selectMode="true" createMode="false" activateAfterCreate="true" createWithinPopup="false" createWithinEditor="false"> <displayed-properties> <group qualifier="General" visible="true" initially-opened="false"> <label key="cockpit.code"/> <property qualifier="ProductWarranty.config.