How to define a translator for an Integration Object Item Attribute -Hybris

721 Views Asked by At

How can we define a translator for an Integration Object Item Attribute in SAP Commerce?

Below screenshot is a sample Integration Object Item Attribute definition.

Is it possible to define a translator for an attribute let us say attribute available in StockLevel. When the inbound requests inserts Integration Object data through odata2webservices API Post calls, the translator should get invoked and executes some business logic and updates the value of attribute (available)

Sample Integration Object Item Attribute definition

2

There are 2 best solutions below

0
On

You can try to create custom Populator (see: DefaultCollectionType2MapPopulator) and insert it into the defaultItemToIntegrationObjectMapConverter. It is important to implement the isApplicable() method correctly.

0
On

Inbound transformation is not really flexible, so you'd better off to have incoming structure as similar as possible to the Model as Hybris is essentially creating the Item first. However, before the persistence you can implement and call a PrePersistHook (you have to specify that as a header in the request with the Spring bean id) where you can actually do whatever you want with the Item, even discarding that.