items.xml in SAP Commerce [Hybris]
The items.xml file specifies types of an extension for defining the data model. By editing the items.xml file, you can define new types or extend existing types. In addition, you can define, override, and extend attributes of the types.
Location of the items.xml file:
The items.xml is located in the resources directory of an extension. The items.xml files are prefixed with the name of their respective extension in the form of extension name-items.xml. For example:
- For the core extension, the file will be core-items.xml.
- For the catalog extension, the file will be catalog-items.xml.
Basic structure of the items.xml file:
The items.xml defines the types for an extension in XML format and the basic structure is as follows:
<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="items.xsd"> <atomictypes/> <collectiontypes/> <enumtypes/> <maptypes/> <relations/> <itemtypes/> </items> |
- items.xml file is validated against an XSD file (items.xsd), so the order of type definitions must conform to this order. If order that doesn’t conform to the items.xsd causes SAP Commerce to fail the extension build.
- We must define types in order of inheritance i.e. more abstract types need to be defined at the beginning of the items.xml file and more concrete types need to be defined more to the end.
- Define a new Item type without extending any existing Item type.
- Define a new Item type by extending existing Item type.
- Define an existing Item type again with new attributes.
<itemtype
code="JobMonitoringLogs"
jaloclass="com.hybris.training.core.jalo.JobMonitoringLogs" autocreate="true" generate="true"> <deployment
table="JobMonitoringLogs" typecode="11000"/> <attributes> <attribute
qualifier="code" type="java.lang.String"
autocreate="true" generate="true"> <persistence
type="property"/> <modifiers
optional="false" unique="true"/> </attribute> <attribute
qualifier="name" type="java.lang.String"
autocreate="true" generate="true"> <persistence
type="property"/> <modifiers/> </attribute> <attribute
qualifier="lastExecutionTime" type="java.util.Date"
autocreate="true" generate="true"> <persistence
type="property"/> <modifiers/> </attribute> <attributes> </itemtype> |
<itemtype
code="ApparelProduct" extends="Product" autocreate="true"
generate="true"
jaloclass="com.hybris.training.core.jalo.ApparelProduct"> <description>Base apparel product
extension that contains additional attributes.</description> <attributes> <attribute
qualifier="genders" type="GenderList"> <description>List of
genders that the ApparelProduct is designed for</description> <modifiers/> <persistence
type="property"/> </attribute> </attributes> </itemtype> |
<itemtype
code="Product" autocreate="false"
generate="false"
jaloclass="com.hybris.training.core.jalo.Product"> <attributes> <attribute qualifier="europe1Taxes"
type="PriceRowCollectionTupe"> <description>Eeurope1 Taxes
</description> <modifiers/> <persistence
type="property"/> </attribute> </attributes> </itemtype> |
Happy Learning,
Ramesh
Comments
Post a Comment