on 2018 Nov 18 12:38 PM
Hello All ,
Iam facing an issue that data mapper doesn't map the field i have just added ,
Steps i have done :-
1) i added erpCustomerCode attribute into AddressWsDTO
/** <i>Generated property</i> for <code>AddressWsDTO.erpCustomerCode</code> property defined at extension <code>myWebservices</code>. */
private String erpCustomerCode;
2)added the same attribute into addressData
/** <i>Generated property</i> for <code>AddressData.erpCustomerCode</code> property defined at extension <code>myFacades</code>. */
private String erpCustomerCode;
3) change the code inside the mapper
validate(address, "address", getAddressDTOValidator());
final AddressData addressData = getDataMapper().map(address, AddressData.class,
"erpCustomerCode,firstName,lastName,titleCode,line1,line2,town,postalCode,country(isocode),region(isocode),defaultAddress,phone");
addressData.setShippingAddress(true);
addressData.setVisibleInAddressBook(true);
final String erpCode = erpUserService.createErpUser(address);
**addressData.setErpCustomerCode(erpCode);**
getUserFacade().addAddress(addressData);
if (addressData.isDefaultAddress())
{
getUserFacade().setDefaultAddress(addressData);
}
return getDataMapper().map(addressData, AddressWsDTO.class, fields);
but i always get this response
{
"country": {
"isocode": "xx"
},
"defaultAddress": false,
"firstName": "xxxx",
"id": "xxxx",
"lastName": "xxxx",
"line1": "xx",
"line2": "",
"phone": "xxx",
"postalCode": "xxx",
"region": {
"isocode": "xxx"
},
"town": "xxx"
}
i have tried to debug but it gives no error in the mapping ,, any idea why my added field (erpCustomerCode) isn't added ?
Thank you.
Request clarification before answering.
Make Sure you have mapped your custom attribute for the Basic, Default and Full level mapping in dto-level-mappings-v2-spring.xml.
as per OOTB the below attributes called for Default
<property name="dtoClass"
value="de.hybris.platform.commercewebservicescommons.dto.user.AddressWsDTO"/>
<property name="levelMapping">
<map>
<entry key="BASIC" value="id"/>
<entry key="DEFAULT"
value="BASIC,firstName,lastName,line1,line2,postalCode,phone,town,region,country,defaultAddress"/>
<entry key="FULL"
value="region(FULL),lastName,titleCode,phone,companyName,country(FULL),id,title,postalCode,email,visibleInAddressBook,formattedAddress,town,firstName,line1,shippingAddress,line2,defaultAddress"/>
</map>
</property>
</bean>
so you have to override in your custom extension/module dto-level-mappings-v2-spring.xml. file and add erpCustomerCode in Default.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Prihan - Instead of directly adding erpCustomerCode attribute into AddressWsDTO and AddressData, please try adding it to the beans.xml. You can refer https://help.hybris.com/1808/hcd/8bbdfe9286691014a741829ebffd8512.html and https://help.hybris.com/1808/hcd/e571a0e6f7524d4ab62e29cc2b387aeb.html to validate if you are missing some step.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.