Defining a New Item Type is So Simple in Hybris

February 1, 2017 | Author: praveenhukumar | Category: N/A
Share Embed Donate


Short Description

Download Defining a New Item Type is So Simple in Hybris...

Description

Defining a new item type is so simple in Hybris? 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 logic. 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

-items.xml 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. java.lang.Boolean.TRUE "catalogVersion" "code" url GLN java.lang.Boolean.TRUE

The above ProductWarranty type definition is created with code as a unique primary key. This type is defined as catalog aware. HMC Configuration: In order to use above type in Hybris HMC we need to add a type definition into hmc.xml file. Let’s go over line by line from the above definition 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'. Default is 'append'. 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.xml) its add some extra information to the item type layouts in HMC (We will see that in next sections.

Organizer contains descriptions on how the different organizer components represent this type. 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 Describes how items of this type look (by default) when they are referenced in a different location. Now let’s see all these sections in HMC

Now above screen in hmc will allow searching for a product warranty based on warranty, active and catalog conditions.

The search results will be displayed in result section after the search. Result section can be configured in list, edit and tree modes by default list (For more information on these modes refer wiki.hybris.com) 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 Though Administration tab was not added to the definition. Hybris will add this tab by default for every new item type defined in hmc.xml.

Now all the sections for the product warranty have been configured in hmc. The question is now how to come to this page? To add an access point for this page. We need to add this product warranty to one of the customized folder or existing folder from the left navigation. Let’s see how to add this access point for this page. Above definition need to be added to hmc.xml file (refer hmc.xsd file on where to mention this entry) Explorertree design the layout of the left navigation. 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. There is one last configuration is still pending. Labels for the Product Warranty. In the hmc.xml for tab, section and explorertree definitions we used keys for labels. But where these keys and its values would be defined?

sbdcore-locales_en.properties 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...description=XY

type.ProductWarranty.name= Product Warranty type.ProductWarranty.code.name=Warranty type.ProductWarranty.active.name=Is Active type.ProductWarranty.catalogVersion.name=Catalog Version

locales_en.properties All the hmc specific labels / localizations are defined locales_en.properties file Sbdgroup = SBD tab.warranty.details= Warranty Details section.warranty.details= Warranty Information tree.ProductWarranty.name= Warranty

This completes the HMC configuration. For more information please look at wiki.hybris.com

Product cockpit configurations Default product cockpit is configured to manage the OOTB and custom products. All the product related information can be maintained in product cockpit. But configuring the product information in not enough in product cockpit. There are various xml configurations are required for making product useful. All the product related attributes (automic or composed types) would require separate xml configurations (e.g ProductWarranty). Before looking into ProductWarranty let’s see how product warranty is related to products.

---------------------------------------------------------------------------------------- Product implementation in SBD. Extends Product List of warranties for the product We will not discuss much on the above product definitions. Let’s see how to configure the Product Warranty xml configurations for product cockpit.

base_ProductWarranty.xml



Base configuration defines base search and sort properties and also product warranty label used wherever product warranty is selected. Search configuration defines on which fields are being considered for a general search in 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.

Sort configuration defines which fields are considering for the sorting. By default the first attribute which is defined under sort properties is considered for sorting.

Labels are used when a product warranty is selected for a product. If not used warranty primary key will be displayed. Since ProductWarranty is a composed type Hybris doesn’t understand how to render the attribute. Hybris understands the automic attributes (e.g. String, Collection etc)

All the Label definitions in cockpit need to be extend AbstractObjectLabelProvider class (Refer wiki for more information) advancedSearch_ProductWarranty.xml Hybris provides a configuration file for advanced search on the product cockpit. All the custom types has to use Hybris advanced search schema definition



editorArea_ProductWarranty.xml editor area defines the layout in product cockpit for creation and updating of ProductWarranty type.

gridview_ProductWarranty.xml Product cockpit provides two layouts grid and list views for search results. For grid view below is the configuration

listviewContentBrowser_ProductWarranty.xml For list view on the product cockpit browser area below definition being used to display the search results .

listViewSelector_ProductWarranty.xml List ivew selector configuration will be used to display the search results when a product warranty type is selected from the reference sections.

wizardConfig_ProductWarranty.xml This is the final file for the type configuration. Wizard configuration defines how the product warranty field would be configured in the cockpits. ( More info refer wiki)

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF