4

Hello I'm trying to learn Hybris and since I don't have access to Wiki site its difficult for me to understand the basics behind the code. Can someone please help me understand the below Impex statements for a text "Welcome to home page" in the home page.

My questions from the below code are ; actually, I have more but don't want to put burden but if you can help me in most basics of Impex statement I will greatly appreciate it.

1) In some place more than one semicolon is used, why?
2) What is uid?
3) It seems values of parameters defined in starts begins after two semicolons (;;) in each statement, let me know I'm correct?

INSERT_UPDATE CMSParagraphComponent;$contentCV[unique=true];uid[unique=true];name;&componentRef;;;;content;
;;welcomeInfoComponent;Welcome information;welcomeInfoComponent;;;;welcome to home page;

INSERT_UPDATE ContentSlotName;name[unique=true];template(uid,$contentCV)[unique=true][default='LandingPage2Template'];validComponentTypes(code);compTypeGroup(code)
;welcomeInfo;;;wide

INSERT_UPDATE ContentSlot;$contentCV[unique=true];uid[unique=true];name;active
;;welcomeInfoSlot;welcome info slot;true

INSERT_UPDATE ContentSlotForTemplate;$contentCV[unique=true];uid[unique=true];position[unique=true];pageTemplate(uid,$contentCV)[unique=true][default='LandingPage2Template'];contentSlot(uid,$contentCV)[unique=true];allowOverwrite
;;WelcomeInfo-LandingPage2;welcomeInfo;;welcomeInfoSlot;true

INSERT_UPDATE ContentSlot;$contentCV[unique=true];uid[unique=true];cmsComponents(uid,$contentCV)
;;welcomeInfoSlot;welcomeInfoComponent
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
sagar
  • 175
  • 1
  • 16
  • I see you have asked many questions here on StackOverflow but haven't accepted any answer. Please have a look at this "[What should I do when someone answers my question?](https://stackoverflow.com/help/someone-answers)" and contribute to SO community – HybrisHelp Nov 12 '18 at 14:59

1 Answers1

6

what is uid?

uid is an attribute defined as unique in CMSItem. Mostly all CMS items extend CMSItem. So you have to give a unique value for all your records in your Impex. Also, uid has been used to declare CMSItem as catalog aware.

<itemtype code="CMSItem" jaloclass="de.hybris.platform.cms2.jalo.contents.CMSItem" extends="GenericItem" autocreate="true"
    generate="true" abstract="true">
    <custom-properties>
        <property name="catalogItemType">
            <value>java.lang.Boolean.TRUE</value>
        </property>
        <property name="catalogVersionAttributeQualifier">
            <value>"catalogVersion"</value>
        </property>
        <property name="uniqueKeyAttributeQualifier">
            <value>"uid"</value>
        </property>
    </custom-properties>
    <attributes>
        <attribute qualifier="uid" generate="true" autocreate="true" type="java.lang.String">
            <persistence type="property" />
            <modifiers optional="false" unique="true" />
        </attribute>
        <attribute qualifier="name" generate="true" autocreate="true" type="java.lang.String">
            <persistence type="property" />
        </attribute>
        <attribute qualifier="catalogVersion" type="CatalogVersion">
            <modifiers optional="false" unique="true" />
            <persistence type="property" />
        </attribute>
    </attributes>
</itemtype>

it seems values of parameters defined in starts begins after two semicolons (;;) in each statement, let me know I'm correct?

Let me first format your impex, so you will get the idea

INSERT_UPDATE CMSParagraphComponent ; $contentCV[unique=true] ; uid[unique=true]     ; name                ; &componentRef        ;  ;  ;  ; content              ;  
                                    ;                         ; welcomeInfoComponent ; Welcome information ; welcomeInfoComponent ;  ;  ;  ; welcome to home page ;  

Here

  • INSERT_UPDATE is mode of your impex
  • CMSParagraphComponent is ItemType
  • Then you have to put ; (semicolon), which is just value separator. From here you can start declaring attribute/column name(e.g uid, name etc) along with modifier(e.g [unique=true]).
  • Now your value should underneath to column define in the first line(call as the header). For some column you don't require to declare value or you want to declare blank value then you just keep it blank as we did for $contentCV
  • Here is $contentCV is the Macro to feed catalogVersion attribute value, which mostly defines at top of the file. During import, these macros are parsed and the macro name is replaced by the macro value. So we are keeping value blank as we don't require to give its value for each value row.

in some place more than one semicolon is used, why?

Just for readability of your file, you can put as many semicolons as you want in your header and same in value row. If you remove those extra ; even though your Impex will run

INSERT_UPDATE CMSParagraphComponent ; $contentCV[unique=true] ; uid[unique=true]     ; name                ; &componentRef        ;  content              ;  
                                    ;                         ; welcomeInfoComponent ; Welcome information ; welcomeInfoComponent ;  welcome to home page ;  
HybrisHelp
  • 5,518
  • 2
  • 27
  • 65
  • 1
    I appreciate your reply, it was very helpful in understanding the code. One last question, what is purpose of &componentRef tag? – sagar Oct 09 '18 at 18:54
  • 1
    `&componentRef` is used to create the reference. So that you can use that reference in some other itemType. Here you can see reference `welcomeInfoComponent` is used in last line (ContentSlot) to bind your component with contentSlot(`welcomeInfoSlot`) – HybrisHelp Oct 10 '18 at 04:52