cancel
Showing results for 
Search instead for 
Did you mean: 

Data Hub: Transform multiple raw attributes into single canonical attribute

Former Member
0 Kudos

Resources that I'm using to test the scenario described below:

  • Data Hub 5.2

  • pcm-apparel-5.2.0.0.jar

  • csv-web-service-5.2.0.0.jar

Scenario:

  • My Raw Item "RawProduct" has two attributes: category and brand

  • My Canonical Item "CanonicalProduct" has an attribute: category

  • My Target Item "ApparelProduct" has an attribute: superCategories

I want to gather the values of "category" and "brand" attributes from RawProduct into the "category" attribute of my CanonicalProduct, later the attribute "superCategories" from ApparelProduct will be populated using the "category" attribute of my CanonicalProduct.

What's the best way to do it?

  • I thought about some solution using Grouping handlers (but maybe it's too much for such an easy task):
    doc: https://wiki.hybris.com/display/release5/Data+Hub+Grouping+-+Technical+Guide

  • Maybe some SpEL expression to "combine" both attributes into a single attribute from Canonical item to Target item using "transformationExpression", but is it possible to do it with collection attributes?

  • Maybe I'm skipping some easier solution such as any specific attribute setup via XML.

Accepted Solutions (1)

Accepted Solutions (1)

Slava
Advisor
Advisor
0 Kudos

Here is another idea to think about. In a few words - add brand attribute to the canonical model in your extension.

This way no custom development is necessary besides defining an additional attribute for the canonical product. We think about canonical model as a normalized presentation of an entity. For that reason it's better to keep data there "neatly organized" into separate attributes. That will make mapping between the canonical model and your raw model trivial. So, instead of combining 'category' and 'brand' inside the canonical model you will combine them in the target model by using the SpEL expressions (what if you also need to export those canonical items to a different target system with different rules of the game). In the attribute mapping for the platform target system you can then add an expression that looks something like this: category + brand (it actually may be more complex if you need to separate them with ',' and each of those fields can be empty. Refer to SpEL guide http://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html for building ternary conditions) for the category attribute, and simply category for the superCategories attribute.

Former Member
0 Kudos

Thanks for you answer, I agree that it is the best way to go, I did try some expressions to combine both values at the target item but no success, so I created this topic to discuss other ideas, I'll put some more efforts on spel.

Thanks again

Answers (1)

Answers (1)

Former Member
0 Kudos

Today Hybris fixed some obsolete restrictions on Data Hub pages, after that the following page is available:

https://wiki.hybris.com/display/release5/SpEL+Expressions+Customization

So, I would say that customizing the Spel expression is a good solution for the scenario that I described above (and many other complex scenarios of course).

Now I wonder: how many other important pages we do not see because of "obsolete restrictions"?

https://answers.sap.com/questions/12750302/data-hub-publication-customization-from-impex-to-a.html?c...

rafal_gdowski
Active Contributor
0 Kudos

Hopefully not many... All of the 5.2 documentation is publicly available. The one that you are referring to was a result of 'human error' :).

More to the point, you can also try to use custom composition handlers (https://wiki.hybris.com/display/release5/Data+Hub+Composition+-+Technical+Guide) if you need more control of what your canonical model will look like.