2018 Dec 31 1:41 PM - edited 2024 Feb 03 5:21 PM
Hi Experts,
I have a requirement where canonical item needs to be created without primary key. E.g. addressId is not required in Address Item. If I try to do this, I am getting following error:
com.hybris.datahub.validation.ValidationException: [ValidationFailure{FATAL, "No primary key is set for canonical item CanonicalCustomer"}] at com.hybris.datahub.validation.AbstractValidator.validate(AbstractValidator.java:32)
Is there a way to define canonical Item without primary key?
Request clarification before answering.
No, there is no way, because how would you create a canonical item out of your raw item without a primary key to determine a match?
And what happens in case of an update? To use your example: how would you know which Address needs to be updated without some kind of primary key?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would highly recommend that you get some kind of ID for the address from the source system, for the reasons mentioned above. I bet they do have some kind of identifier, even if you have to be a bit creative (e.g. use the customer ID as address ID, in case a customer can only have a single address)
If that isn't an option, then you have to generate some kind of unique identifier when loading the raw items. Maybe you can write a Spel Expression to generated a GUID in the canonical XML file, or you have to provide it later in the processing with a grouping handler (never tried that).
But you may amass a lot of unnecessary data in SAP Commerce that way. Every address has a new unique id, even updates for existing addresses -> every update is a new address in SAP Commerce, if you don't have some special handling during publish / import of the data in Commerce.
In other words, just because you have the requirement that addresses don't have a primary key, doesn't mean that the requirement makes sense or is even feasible when integrating data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.