cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

OOTB class LocalizedCompositionHandler not working for custom attribute in datahub

Former Member
0 Likes
432

Hi All,

I create one custom canonical attribute summary in CanonicalProductSales in datahub , which is mapped with raw attribute E1MARAM-E1MAKTM-MAKTX. As this attribute have multiple language specific values I create new bean in my customraw-datahub-extension-spring.xml to replicate all the values as per their language code as below.

 <bean id="cgiProductShortTextCompositionHandler" class="com.hybris.datahub.saperpproduct.composition.LocalizedCompositionHandler">
         <property name="canonicalAttribute" value="shortText" />
         <property name="canonicalTypeCode" value="CanonicalProductSales" />
         <property name="rawAttribute" value="E1MARAM-E1MAKTM-MAKTX" />
         <property name="rawAttributeISO" value="E1MARAM-E1MAKTM-SPRAS_ISO" />
         <property name="rawTypeCode" value="RawMATMAS" />
     </bean>

My IDOC contains below values of E1MARAM-E1MAKTM-MAKTX

 <MAKTX>PARTS
 F/GARAGE
 DOOR
 OPEN(LENS-ASSY)</MAKTX><SPRAS_ISO>Z9</SPRAS_ISO></E1MAKTM><E1MAKTM
 SEGMENT="1"><MSGFN>005</MSGFN><SPRAS>E</SPRAS><MAKTX>LIGHT
 LENS</MAKTX><SPRAS_ISO>EN</SPRAS_ISO></E1MAKTM><E1MAKTM
 SEGMENT="1"><MSGFN>005</MSGFN><SPRAS>S</SPRAS><MAKTX>MANUFACTURAS
 DE
 PLASTICO</MAKTX><SPRAS_ISO>ES</SPRAS_ISO></E1MAKTM>


It should replicate all the three values, but now its replicating only last value

Custom attribute :- customraw-datahub-extension.xml CanonicalProductSales <attributes> <!-- Custom raw attribute mapping with canonical shortText attribute --> <attribute> <name>shortText</name> <transformations> <transformation> <rawSource>RawMATMAS</rawSource> <expression></expression> </transformation> </transformations> </attribute> customcanonical-datahub-extension.xml <!-- Start of canonical item for CanonicalProductSales --> <type>CanonicalProductSales</type> <attributes> <attribute> <name>summary</name> <model> <localizable>true</localizable> <type>String</type> </model> </attribute> customtarget-datahub-extension.xml

 <attribute>
                             <name>summary</name>
                             <localizable>true</localizable>
                             <transformationExpression>summary</transformationExpression>
                             <exportCode>summary</exportCode>
                         </attribute>
 

I noticed that their is one OOTB canonical attribute name which is mapped with E1MARAM-E1MAKTM-MAKTX, for the attribute name all the three values are getting replicated.

For OOTHB attribute its replicating all the three values, but not for my custom attribute, Is their any thing missing while creation of custom attribute ?

Regards, Rasika

Accepted Solutions (1)

Accepted Solutions (1)

former_member224482
Active Contributor
0 Likes

I create one custom canonical attribute summary in CanonicalProductSales in datahub , which is mapped with raw attribute E1MARAM-E1MAKTM-MAKTX.
This is a mistake as E1MAKTM is not a child segment of E1MVKEM. Only the fields under E1MVKEM shall be mapped to CanonicalProductSales.

It should replicate all the three values, but now its replicating only last value.
No, it should not repeat the three values. Segments E1MAKTM and E1MVKEM are hierarchically independent and therefore cannot be map/reduced into the same data structure linearly.

I noticed that their is one OOTB canonical attribute name which is mapped with E1MARAM-E1MAKTM-MAKTX, for the attribute name all the three values are getting replicated.
There is no reason to define an additional summary field for the same input.

Solution :
Do not create canonical attribute summary in CanonicalProductSales for duplicating an already mapped field.

Simply use the resolve method in the target definition. Example :
<transformationExpression>resolve('CanonicalProduct').name</transformationExpression>

Former Member
0 Likes

I agree that I need to use OOTB canonical attribute name

But I want E1MARAM-E1MAKTM-MAKTX with language = EN , so for this I create custom attribute shortText and custom handler to filter MAKTX with language = EN

Is their any way to use custom composition hanlder instead of OOTB LocalizedCompositionHandler for OOTB canonical attribute name?

former_member224482
Active Contributor
0 Likes

There is no need of a custom handler for such a simple filtering logic. Use a SpEL expression into a non localize attribute.

CanonicalProduct attribute name is already localized and it shall not be altered.

Answers (0)