Hybris Interview Questions -items.xml

Q.1 What is the location of items.xml in Hybris?

Ans : Items.xml is extension specific . Every Extension has resources folder in which you can find items.xml file which perfix the extension name . The syntax is extensioname-items.xml.  For Example : core-items.xml or cockpit-items.xml.

Q .2 What is the basic structure of an Items.xml ?
Ans : The basic sturcture of an items.xml is


Q3. Can the order of the defined itemtypes vary in item.xml?
Ans : No , all the itemtypes defined should be in the order defined above otherwise it ll lead to a build error.

Q4 . How can you define a new item type in items.xml?
Ans : A new item type can be defined using the <itemtypes> tag which should include the code and description attributes of the defined item type.eg:
<itemtype code="NewType"
    generate="true" >

Q5. What is the meaning of various attributes used in defining a new itemtype?
Ans :

1. code: code is the name of the itemtype you defined . For eg. in aove mentioned example NewType is the name of the itemtype I have created.

2. extends : extends attribute represents the parent of the new itemtype defined as in the above example Product item the parent of the NewType item defined.

3.autocreate : autocreate attrbiute can take only boolean value such as true and false. Setting autocreate element to true, which lets the hybris Commerce Suite create a new database entry for this type at initialization/update process. Setting the autocreate modifier to false causes a build failure if we are defining a new subtype if you are just adding an attribute the already defined item then autocreate can be set to false as it already has a database entry.

4. generate : This attribute allows the creation of a new Model (Java class) for the new itemtype defined .Setting it to false will lead to non creation of the model class due to which there wont be any build error but you wont be able to use the getter /setters of the attributes defined.

Q6. How an items.xml is verified or validated?
Ans : In your extension's directory /resources folder an item.xsd file exists which  using which Hybris commerce Suite validated the items.xml against items.xsd.Any discrepancy caused between two files lead to build failure.

Q7. After creating a new itemtype which layers are effected and how many new classes are created?
Ans :
1. JaloLayer: under gensrc directory of that Extension ->Generated*.java  and gensrc directory is refreshed.
2. Service Layer: Generate model classes as *Model.java under bootstrap/gensrc directory in service layer .
3. *DTO .java and *resources.java :Webservice-related classes which are created to support CRUD logic via RESTful URIs. These classes are only generated when the optional extension platformwebservices is included in your configuration.
4. *java : In JaloLayer which extends the *Generated.java class.

SO in Total 5 new Java classes are created .

                                             Model service create method vs new operator - Hybris Interview question

Q.8 How to make cronjob run on some servers(in case of load balancer or cluster ) and  but not on others?

Ans : Read Here 

Q.9 How can you add values to a collection type attribute and Map from Impex in Hybris ?

Ans : Read Here

Q.10 Difference between ant all and ant clean all in hybris .

Ans .  Read Here .

How to run 2 hybris servers on same machine ?

How to run multiple hybris instances on same machine?

Post a Comment