cancel
Showing results for 
Search instead for 
Did you mean: 

How to update the customer using Impex

Former Member
0 Kudos

Hi

I'm new to the hybris and learning the concepts of it. I would like to update the customer using impex script. I tried with below one

 UPDATE Customer;code[unique=true];eflyer;
 uday.madigatla@gmail.com;true;

When i validated the script in HAC, it says..

 ERROR [hybrisHTTP1] [DefaultImpexFacade] ImpEx script validation has failed: unknown attribute 'code
 ' in header 'UPDATE Customer'

So removed the 'code' and replaced with customerid. It validated correctly, but when i executed it, it throws me an error saying that...

 ERROR [hybrisHTTP8] (00000RS1) [Importer] line 2 at main script: Exception 'unknown type 'uday.madig
 atla@gmail.com' in line ValueLine[,line 2 at main script,uday.madigatla@gmail.com,HeaderDescriptor[l
 ine 1 at main script, update, Customer, {}, [customerid, eflyer] ],{1=ValueEntry('false'=null,unreso
 lved=null,ignore=false), 2=ValueEntry(''=null,unresolved=null,ignore=false)}] - cannot import' in ha
 ndling exception: unknown type 'uday.madigatla@gmail.com' in line ValueLine[,line 2 at main script,u
 day.madigatla@gmail.com,HeaderDescriptor[line 1 at main script, update, Customer, {}, [customerid, e
 flyer] ],{1=ValueEntry('false'=null,unresolved=null,ignore=false), 2=ValueEntry(''=null,unresolved=n
 ull,ignore=false)}] - cannot import

Can you please help me here to update the customer info using impex. Sample impex would help me.

Accepted Solutions (0)

Answers (4)

Answers (4)

Brenda_Glez
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Uday,

There is a way to get the headers of all the itemtypes in the platform, you have to go into "hMC/System/Tools/Script Generator".

You should have something like the following:

 insert_update Customer;&Item;@password[translator=de.hybris.platform.impex.jalo.translators.UserPasswordTranslator];CN;DN;Europe1PriceFactory_UDG(code,itemtype(code));Europe1PriceFactory_UPG(code,itemtype(code));Europe1PriceFactory_UTG(code,itemtype(code));addresses(&Item);authorizedToUnlockPages[allownull=true];carts(code);creationtime[forceWrite=true,dateformat=dd.MM.yyyy hh:mm:ss];customerID;defaultPaymentAddress(&Item);defaultPaymentInfo(&Item);defaultShipmentAddress(&Item);description;domain;encodedPassword;europe1Discounts(&Item);hmcLoginDisabled;lastLogin[dateformat=dd.MM.yyyy hh:mm:ss];ldapaccount[allownull=true];ldaplogin;ldapsearchbase;loginDisabled[allownull=true];name;orders(code,versionID);originalUid;owner(&Item);password;passwordAnswer;passwordEncoding;passwordQuestion;paymentInfos(&Item);previewCatalogVersions(catalog(id),version);profilePicture(catalogVersion(catalog(id),version),code);sessionCurrency(isocode);sessionLanguage(isocode);title(code);token;type(code,itemtype(code));uid[unique=true,allownull=true];userprofile(&Item)

Then you just have to remove the fields you don't need and execute it again.

Regards, Brenda

Former Member
0 Kudos

Hi Uday In your case, the impex would look like as :

 INSERT_UPDATE Customer;uid[unique=true];eflyer;
 ;uday.madigatla@gmail.com;true;

In general, for any implementation that you need for your own customized purpose, you should create your own customer item type which will extends the core hybris "Customer" and then you can put a mandatory and unique attribute constraint (may be email ID as stated in this case) This would look like something as below :

     <itemtype code="MyCustomer" extends="Customer" autocreate="false" generate="false">
     <attribute autocreate="true" qualifier="emailId" type="java.lang.String">
         <modifiers unique="true" optional="false" />
             <persistence type="property" />
     </attribute>
     .
     .
     .
     </itemtype>
 

Please find below the entire insert_update statement for Customer item type. You can see the same and customize it for your own needs.

 insert_update Customer;&Item;@password[translator=de.hybris.platform.impex.jalo.translators.UserPasswordTranslator];CN;DN;Europe1PriceFactory_UDG(code,itemtype(code));Europe1PriceFactory_UPG(code,itemtype(code));Europe1PriceFactory_UTG(code,itemtype(code));addresses(&Item);authorizedToUnlockPages[allownull=true];carts(code);creationtime[forceWrite=true,dateformat=dd.MM.yyyy hh:mm:ss];customerID;defaultPaymentAddress(&Item);defaultPaymentInfo(&Item);defaultShipmentAddress(&Item);description;domain;encodedPassword;europe1Discounts(&Item);hmcLoginDisabled;lastLogin[dateformat=dd.MM.yyyy hh:mm:ss];ldapaccount[allownull=true];ldaplogin;ldapsearchbase;loginDisabled[allownull=true];name;orders(code,versionID);originalUid;owner(&Item)[allownull=true];password;passwordAnswer;passwordEncoding;passwordQuestion;paymentInfos(&Item);previewCatalogVersions(catalog(id),version);profilePicture(catalogVersion(catalog(id),version),code);sessionCurrency(isocode);sessionLanguage(isocode);title(code);token;type(code,itemtype(code));uid[unique=true,allownull=true];userprofile(&Item)

Hope this helps.

Former Member
0 Kudos

Hi,

as long as you did not define such an attribute called 'code' on the 'Customer' type, you wont find it. Maybe you want to update the Customers 'uid' attribute (inherited from Principal) ?

former_member632755
Active Contributor
0 Kudos

Hi,

without going into details, the second line is missing the leading ;. Correct code would be:

     UPDATE Customer;code[unique=true];eflyer;
     ;uday.madigatla@gmail.com;true;

Customer type is oint his case automaticly infered. In case you wanted to change the type without changing the header you are allowed to do it via explicit declaration, like for example:

     UPDATE Customer;code[unique=true];eflyer;
     MyCustomerSubtype;uday.madigatla@gmail.com;true;

You will find the details in the impex docuemtation on the wiki.

Cheers, Wojtek

Former Member
0 Kudos

Hi Wojtek,

I updated the impex like below..

 UPDATE Customer;code[unique=true];eflyer;
 ;uday.madigatla@gmail.com;true;

But still the error persists...

 ERROR [hybrisHTTP9] [DefaultImpexFacade] ImpEx script validation has failed: unknown attribute 'code' in header 'Update Customer'

Please help me.