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

Setting default value in canonical extension file of data hub

Former Member
0 Likes
401

Hi Experts,

I want to set a default value for an attribute so that the default value will be set if value is not set in CSV file. I tried following in canonical extension file but it didn't work:

 <name>Count</name>
     <model>
         <localizable>false</localizable>
         <collection>false</collection>
         <type>String</type>
         <primaryKey>false</primaryKey>
         <default>"00"</default>
     </model>


Can you please help me with this?

Accepted Solutions (0)

Answers (2)

Answers (2)

Slava
Product and Topic Expert
Product and Topic Expert
0 Likes

Kaushik,

unfortunately canonical item model does not support default values for attributes - all attributes must be explicitly composed with values or the attribute value is going to be null. If applying a default value in the target model works, continue with the Gopinath's advice because it's going to be simpler.

If not and you indeed need to have a default value in the canonical model, then you can create a custom CompositionRuleHandler, which may delegate to BasicAttributeCompositionRuleHandler in the compose method. If that basic handler did not populate the desired attribute in the canonical item, you wrapper can populate the attribute value with the default value. See https://help.hybris.com/1808/hcd/24ed563d68ab40b0822f2e21165a90a0.html for more information and an example.

Former Member
0 Likes

Hi Kaushik,

Please set the default value in the target.xml instead of canonical.xml:

 <attribute>
 <name>Count</name>
 <localizable>false</localizable>
 <collection>false</collection>
 <exportCode>Count[default=0]</exportCode>
 <mandatoryInHeader>false</mandatoryInHeader>
 </attribute>

Thanks,

G Gopinath.