defining a new item type is so simple in hybris

Upload: praveenhukumar

Post on 26-Feb-2018

215 views

Category:

Documents


3 download

TRANSCRIPT

  • 7/25/2019 Defining a New Item Type is So Simple in Hybris

    1/11

    Defning a new item type is so simple in

    Hybris?

    Starting on Hybris platform as a beginner thought that dening an item type in

    Hybris so simple by adding its entry in items.xml le. Yes this is true; In Hybris allthe type denitions are dened in items.xml le under the custom extension.

    Hybris will create corresponding table denitions, column types and relationships in

    the underlying data base leaing the deeloper to only concentrate on business

    logic.

    !fter haing a good amount of experience on Hybris platform now considering

    aboe statement is not "##$ true. %onsidering the H&% 'Hybris &anagement

    %onsole( and )roduct coc*pit it is not enough to add the type denition into

    items.xmlle. +here are so many les that we need to write in order to ma*e a

    type aailable completely useable in the hybris system.

    et-s explore what would be reuired to create a new item type ')roduct/arranty(

    denition in Hybris

    -items.xml

    !ll the new type denitions in the hybris system are dened in items.xml le.

    +his le is used to structure the database ob0ects for the hybris serice layer.

    1itemtype code23ProductWarranty3 extends234enericItem3autocreate23true3 generate23true35

    1deployment table23/arranties3 typecode23"6"783 95

    1custom:properties5

    1property

    name23catalogItem+ype351alue50aa.lang.oolean.+19alue519property

    5

    1property

    name23catalog?ersion!ttribute@ualier351alue53catalog?ersion319alue519p

    roperty5

    1propertyname23uniueAey!ttribute@ualier351alue53code319alue519property5

    19custom:properties5

    1attributes5

  • 7/25/2019 Defining a New Item Type is So Simple in Hybris

    2/11

    uniue23true3

    search23true3 95

    1persistence type23property3 95

    19attribute5

  • 7/25/2019 Defining a New Item Type is So Simple in Hybris

    3/11

    width236##3519attribute5

    1attribute name23actie3 519attribute5

    1attribute name23catalog?ersion3

    width236##35 19attribute5

    19itemlayout5

    19listiew5

    19result5

    1editor5

    1tab name23tab.warranty.details35

    1section name23section.warranty.details35

    1listlayout5

    1attribute name23code3

    width236##3519attribute5

    1attribute name23actie3 519attribute5

    1attribute name23catalog?ersion3width236##35 19attribute5

    19listlayout5

    19section5

    19tab5

    19editor5

    19organiCer5

    1defaultreference searchattribute23code3 mode23replace35

    1itemlayout5

    1attribute name23code395

    19itemlayout5

    19defaultreference5

    19type5

    et-s go oer line by line from the aboe denition

  • 7/25/2019 Defining a New Item Type is So Simple in Hybris

    4/11

  • 7/25/2019 Defining a New Item Type is So Simple in Hybris

    5/11

    +he search results will be displayed in result section after the search. xplorertree design the layout of the left naigation. ! folder with SE iscreated and a reference lin* for the product warranty has been created

    Bow all the conguration for the )roduct /arranty in H&% is established.+here is one last conguration is still pending. abels for the )roduct/arranty. In the hmc.xml for tab, section and explorertree denitions weused *eys for labels. ut where these *eys and its alues would be dened

  • 7/25/2019 Defining a New Item Type is So Simple in Hybris

    6/11

    sbdcore-locales/en.properties!ll the localiCation parameters are dened into this properties le and inHybris there is a predened structure to add labels for item types

    J syntax for type localiCationsKJ

    J type.1code of type5.name2LY

    J type.1code of type5.1ualier of attribute5.name2LY

    J type.1code of type5.description2LY

    J type.1code of type5.1ualier of attribute5.description2LY

    type.)roduct/arranty.name2 )roduct/arranty

    type.)roduct/arranty.code.name2/arranty

    type.)roduct/arranty.actie.name2Is!ctie

    type.)roduct/arranty.catalog?ersion.name2%atalog?ersion

    locales/en.properties!ll the hmc specic labels 9 localiCations are dened localesMen.properties le

    Sbdgroup 2 SE

    tab.warranty.details2 /arrantyEetails

    section.warranty.details2 /arrantyInformation

    tree.)roduct/arranty.name2 /arranty

    +his completes the H&% conguration. or more information please loo* atwi*i.hybris.com

    Product coc0pit confgurations

    Eefault product coc*pit is congured to manage the FF+ and customproducts. !ll the product related information can be maintained in productcoc*pit. ut conguring the product information in not enough in productcoc*pit. +here are arious xml congurations are reuired for ma*ing productuseful. !ll the product related attributes 'automic or composed types( would

    reuire separate xml congurations 'e.g )roduct/arranty(. efore loo*inginto )roduct/arranty let-s see how product warranty is related to products.

    1collectiontype elementtype23)roduct/arranty3

    code23)roduct/arranty%ollection3

    autocreate23true3 95

  • 7/25/2019 Defining a New Item Type is So Simple in Hybris

    7/11

    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    1itemtype code23SE)roduct3 extends23)roduct3 autocreate23true3

    generate23true35

    1description5)roduct implementation in SE.

    >xtends )roduct 19description5

    1attributes5

    1attribute type23)roduct/arranty%ollection3

    ualier2 3warranties35

    1persistence

    type23property3519persistence5

    1modiers read23true3 search23true3

    optional23true3

    write23true3

    dontFptimiCe23true3519modiers51description5ist of warranties for the

    product19description5

    19attribute5

    19attributes5

    19itemtype5

    /e will not discuss much on the aboe product denitions. et-s see how tocongure the )roduct /arranty xml congurations for product coc*pit.

    base/ProductWarranty.xml

    1xmlersion2"1.0"encoding2"UTF-8"5

    1base5

    1search5

    1search:properties5

    1propertyualier2"ProductWarranty.code"95

    1propertyualier2"ProductWarranty.catalogVersion"95

    19search:properties5

    1sort:properties5

    1propertyualier2"ProductWarranty.code"95

    1propertyualier2"ProductWarranty.catalogVersion"95

    1propertyualier2"ProductWarranty.active"95

    1propertyualier2"Item.pk"95

    19sort:properties5

    19search5

    1labelspring:bean2"sdProductWarranty!aelProvider" 95

  • 7/25/2019 Defining a New Item Type is So Simple in Hybris

    8/11

    19base5

    ase conguration denes base search and sort properties and also productwarranty label used whereer product warranty is selected.

    $earc+conguration denes on which elds are being considered for ageneral search in product coc*pit. !ny text entered in base search eld'refer wi*i( will be carried search on code and catalog?ersion is consideredbased on the user catalog access for the )roduct/arranty.

    $ortconguration denes which elds are considering for the sorting. ydefault the rst attribute which is dened under sort properties is consideredfor sorting.

    1abelsare used when a product warranty is selected for a product. If notused warranty primary *ey will be displayed. Since )roduct/arranty is acomposed type Hybris doesn-t understand how to render the attribute.Hybris understands the automic attributes 'e.g. String, %ollection etc(

    !ll the abel denitions in coc*pit need to be extend2bstract3b"ect1abelPro#ider class '

  • 7/25/2019 Defining a New Item Type is So Simple in Hybris

    9/11

    1xmlersion2"1.0"encoding2"UTF-8"5

    1adanced:search5

    1groupname2"root"type2"ProductWarranty"5

    1label*ey2"cong.general.searc#$or"95

    1propertyualier2"ProductWarranty.code"95

    1propertyualier2"ProductWarranty.catalogVersion"95

    1propertyualier2"ProductWarranty.active"95

    19group5

    19adanced:search5

    editor2rea/ProductWarranty.xmleditor area denes the layout in product coc*pit for creation and updating of)roduct/arranty type.

    grid#iew/ProductWarranty.xml

    )roduct coc*pit proides two layouts grid and list iews for search results.or grid iew below is the conguration

  • 7/25/2019 Defining a New Item Type is So Simple in Hybris

    10/11

    1xml ersion23".#3 encoding23=+:N35

    1grid:iew5

    1labelslot5

    1property ualier23)roduct/arranty.name3 95

    19labelslot5

    1descriptionslot5

    1property ualier23)roduct/arranty.name3 95

    19descriptionslot5

    19grid:iew5

    list#iew(ontent&rowser/ProductWarranty.xml

    or list iew on the product coc*pit browser area below denition being usedto display the search results .

    1xmlersion2"1.0"encoding2"UTF-8"51list:iewunassigned:group:name2"%t#er"5

    1groupname2"&eneral"5

    1propertyualier2"ProductWarranty.code"isible2"true"editable2"$alse"95

    1propertyualier2"ProductWarranty.catalogVersion"isible2"true"

    editable2"$alse"95

    1propertyualier2"ProductWarranty.active"isible2"true"

    editable2"$alse"95

    19group5

    19list:iew5

    list'iew$elector/ProductWarranty.xml

    ist iew selector conguration will be used to display the search resultswhen a product warranty type is selected from the reference sections.

  • 7/25/2019 Defining a New Item Type is So Simple in Hybris

    11/11

    wi,ard(onfg/ProductWarranty.xml

    +his is the nal le for the type conguration. /iCard conguration deneshow the product warranty eld would be congured in the coc*pits. ' &oreinfo refer wi*i(

    1xmlersion2"1.0"encoding2"UTF-8"5

    1wiCard:cong select&ode2"true"create&ode2"$alse"actiate!fter%reate2"true"

    create/ithin)opup2"$alse"create/ithin>ditor2"$alse"5

    1displayed:properties5

    1groupualier2"&eneral"isible2"true"initially:opened2"$alse"5

    1label*ey2"cockpit.cong.lael.&eneral"951propertyualier2"ProductWarranty.code"95

    1propertyualier2"ProductWarranty.active"95

    1propertyualier2"ProductWarranty.catalogVersion"95

    19group5

    19displayed:properties5

    19wiCard:cong5