‎2018 Jan 27 7:48 AM - edited ‎2024 Feb 04 4:08 AM
Some of the items which are in target-items.xml file not exists in cononical-items.xml file. I thought whatever is in the target-items.xml file should be in canonical-items.xml file.
Example - target-items.xml file has this attribute.
<name>b2bUnitName</name>
<transformationExpression>resolve('CanonicalParty').name</transformationExpression>
<exportCode>Name</exportCode>
The name attribute not exists in canonical-items.xml file but only exists in raw-items.xml file?
Q= When do we need to define the attributes / items in the canonical items.xml file? Are all the attributes exists in target items need to be in the canonical items.xml file? Some times I am seeing some of the attributes but not all of them in the canonical-items.xml file.
Thanks.
Request clarification before answering.
In general, canonical item definitions are defined in the *-canonical-datahub-extension.xml, raw types are defined in *-raw-datahub-extension.xml, and target types defined in *-target-datahub-extension.xml. It is best practice to put the raw -> canonical transformations in the *-raw-datahub-extension.xml file and the canonical -> target transformations in the *-target-datahub-extension.xml. But it is not always the case with legacy extensions.
In the example you gave above, the b2bUnitName attribute on the TargetItem (which is unknown to me since it's not in the code snippet) is mapped by looking up the name attribute on the CanonicalParty type. So name must be defined on the CanonicalParty type. Types can be extended, so if you don't see CanonicalParty in your *-canonical-datahub-extension.xml file, or if you don't see the attribute name on CanonicalParty, it means that it is defined on it's parent type. There will be a dependency on another extension where CanonicalParty is defined. Dependencies are usually defined at the top of the extension xml file in the following format:
<dependencies>
<dependency>
<extension>my-extension</extension>
</dependency>
</dependencies>
So I can define CanonicalParty type in my-extension. Then I can extend it to have additional attributes in another extension without repeating the attributes that I defined in my-extension.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the nice explanation. What explained about the relation ship is not clear in the documentation. Now I am clear on it. This name not clear for me..
<targetItems>
<item>
<type>Company</type>
<exportCode>B2BUnit</exportCode>
<description>Company</description>
<canonicalItemSource>CanonicalParty</canonicalItemSource>
<updatable>true</updatable>
<attributes>
<attribute>
<name>uid</name>
<transformationExpression>externalPartyId</transformationExpression>
<exportCode>uid[unique=true]</exportCode>
<mandatoryInHeader>true</mandatoryInHeader>
</attribute>
<attribute>
<name>b2bUnitName</name>
<transformationExpression>name</transformationExpression>
<exportCode>Name</exportCode>
</attribute>
</attributes>
</item>
If you see b2bUnitName --> where exactly used this b2bUnitName? uid --> Where exactly the uid is used? Basically I didn't find the purpose of name tag.
The value of the property b2bUnitName on type Company is assigned from the value of the property name on CanonicalParty. Same goes for externalPartyId -> uid.
The properties on the Target Item are used during export. So in the case of exporting to a Hybris target system, those target items are used to generate ImpEx. But if you export to a different target system, you can create an adapter that will grab the property values from Target Item values for a different purpose.
I didn't expect that answer from you. I posted after reading documentation only.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi , please go through the Data Hub tutorials. They will answer many of your questions: https://help.hybris.com/6.6.0/hcd/8ba79fcc86691014a83e8530484d3892.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.