cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Impex concept:how to write impex for one to many?

Hari_prasad
Participant
0 Kudos
2,701

I have created two items type and for these item type i have defined one to many relationship using Relation tag.How can i write impex for this relation?

Thanks and regards

preeti

sushma

Accepted Solutions (1)

Accepted Solutions (1)

arvind-kumar_avinash
Active Contributor

I hope you should be able to write your ImpEx with the help of the following example:

<relation code="Country2RegionRelation" generate="true" localized="false" autocreate="true">
    <sourceElement type="Country" qualifier="country" cardinality="one">
        <modifiers read="true" write="true" search="true" optional="false" unique="true"/>
    </sourceElement>
    <targetElement type="Region" qualifier="regions" cardinality="many">
        <modifiers read="true" write="true" search="true" partof="true"/>
    </targetElement>
</relation>


<itemtype code="Country"
          extends="C2LItem"
          jaloclass="de.hybris.platform.jalo.c2l.Country"
          autocreate="true"
          generate="true">
    <deployment table="Countries" typecode="34"/>
    <attributes>
        <attribute qualifier="isocode" type="java.lang.String" redeclare="true" generate="false">
            <modifiers read="true" write="true" search="true" optional="false" unique="true"/>
        </attribute>
    </attributes>
</itemtype>


<itemtype code="Region"
          extends="C2LItem"
          jaloclass="de.hybris.platform.jalo.c2l.Region"
          autocreate="true"
          generate="true">
    <deployment table="Regions" typecode="35"/>
    <attributes>
        <attribute autocreate="true" qualifier="country" type="Country">
            <persistence type="property"/>
            <modifiers read="true" write="true" search="true" optional="false" unique="true"/>
        </attribute>
        <attribute qualifier="isocode" type="java.lang.String" redeclare="true" generate="false">
            <modifiers read="true" write="true" search="true" optional="false" unique="true"/>
        </attribute>
    </attributes>
    <indexes>
        <index name="Region_Country">
            <key attribute="country"/>
        </index>
    </indexes>
</itemtype>

ImpEx to insert data:

INSERT_UPDATE Country;isocode[unique=true]
;US


INSERT_UPDATE Region;country(isocode);isocode[unique=true]
;US;US-AL
;US;US-AK
;US;US-AZ
;US;US-AR
;US;US-CA
Hari_prasad
Participant
0 Kudos

THANK YOU

Answers (0)