Exercise: Create a Target Item Extension XML File

Using the following example, create a target extension xml file for variant data called target-with-variants-datahub-extension.xml. The target system is the SAP Commerce Cloud, so you are going to use the Data Hub Adapter.

So what is different about this target extension XML file as opposed to ones you have created earlier?
  • In the export codes section, there are export codes that are pushed into ImpEx and used by SAP Commerce Cloud.
  • In the targetItems section, each type attribute has an exportCode value and a mandatoryInHeader value. Both of these values are related to the ImpEx script generated by Data Hub when working with SAP Commerce Cloud.
  • There is a new type called Category. When thinking about how this type is used, visualize how shoe might be the parent of a product family. Then consider how high heel and open toed strapless would be children of the parent shoe. In this way, Data Hub organizes products into categories, and their variants are linked to the categories.
  • The TargetItems section has two types you have not seen, ApparelColorVariantProduct and ApparelSizeVariantProduct. The presence of two variant types is significant, because the raw and canonical exercises only defined one. So even though you have been working with only one variant type up to now, you can choose to split the data further during publication.

Using the following instructions, you create a target extension xml file for variant data. The XML definition is based on the one dimensional data file defined in the topic Addressing Variant Data (see Related Links). You can download an answer to this exercise from the Solution Book.

Create an empty folder for working. Using the following example, create a target extension xml file called target-with-variants-datahub-extension.xml.
  1. The extensions XML file has a dependency on canonical-with-variants-datahub-extension.
  2. The targetSystem section is different, because it includes exportCodes. Both exportCode blocks are included as they are not intuitive.
            	  <name>HybrisCommerceInstallation</name>
            	  <type>HybrisCore</type>
            	  <exportURL>${datahub.extension.exportURL}</exportURL>
            	  <userName>${datahub.extension.userName}</userName>
            	  <password>${datahub.extension.password}</password>
    			<exportCodes>
    				<exportCode>
    					$catalogVersion=catalogversion(catalog(id[default=apparelProductCatalog]),version[default='Staged'])[unique=true,default=apparelProductCatalog:Staged]
    				</exportCode>
    				<exportCode>
    					$baseProduct=baseProduct(code,catalogVersion(catalog(id[default='apparelProductCatalog']),version[default='Staged']))
    				</exportCode>
    			</exportCodes>
  3. Declare the canonical attributes for the type ApparelProduct.
  4. A partial piece of the XML for the first variant:
    			<item>
    					<type>ApparelColorVariantProduct</type>
    					<exportCode>ApparelStyleVariantProduct</exportCode>
    					<description>Color Variant for an Apparel Product</description>
    					<updatable>true</updatable>
    					<canonicalItemSource>CanonicalVariant</canonicalItemSource>
    					<status>ACTIVE</status>
    					<attributes>
    						<attribute>
    							<name>code</name>
    							<localizable>false</localizable>
    							<collection>false</collection>
    							<transformationExpression>product + '-1'</transformationExpression>
    							<exportCode>code[unique=true]</exportCode>
    							<mandatoryInHeader>true</mandatoryInHeader>
    						</attribute>
  5. A partial piece of the XML for the second variant:
    				<item>
    					<type>ApparelSizeVariantProduct</type>
    					<exportCode>ApparelSizeVariantProduct</exportCode>
    					<description>Size Variant for an Apparel Product</description>
    					<updatable>true</updatable>
    					<canonicalItemSource>CanonicalVariant</canonicalItemSource>
    					<status>ACTIVE</status>
    					<attributes>
    						<attribute>
    							<name>code</name>
    							<localizable>false</localizable>
    							<collection>false</collection>
    							<transformationExpression>SKU</transformationExpression>
    							<exportCode>code[unique=true]</exportCode>
    							<mandatoryInHeader>true</mandatoryInHeader>
    						</attribute>
  6. A partial piece of the XML for the Category type:
    				<item>
    					<type>Category</type>
    					<exportCode>Category</exportCode>
    					<description>Product Category</description>
    					<updatable>true</updatable>
    					<canonicalItemSource>CanonicalCategory</canonicalItemSource>
    					<status>ACTIVE</status>
    					<attributes>
    						<attribute>
    							<name>code</name>
    							<localizable>false</localizable>
    							<collection>false</collection>
    							<transformationExpression>integrationKey</transformationExpression>
    							<exportCode>code[unique=true]</exportCode>
    							<mandatoryInHeader>true</mandatoryInHeader>
    						</attribute>