‎2018 Dec 13 11:27 AM - edited ‎2024 Feb 03 5:17 PM
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?
Request clarification before answering.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.