HCL Commerce Version 9.0.1.11 or later

Creating and managing variants using Data Load

You can use Data Load to create, read, update and delete product variants. Optionally, you can also use data load to maintain the catalog entry relationship between a variant and its children SKUs.

About this task

There are two approaches to loading product variant data. Which you use depends on whether you expect the Data Load utility to automatically resolve and maintain the  catalog entry relationship between a variant and its children SKUs.  You can control this behavior using a Data Load configuration property named resolveAndAssociateVariantItems.

Note: While product variants behave similarly to products in most respects, there are important differences in how they are created.
  • You cannot create duplicate variant as you can with a product. For example, having created one variant using the red attribute, you cannot create a second variant based on the red attribute.
  • For a given product, if there is already a variant defined using a particular attribute, the product cannot be used to create variants using a different attribute. For example, if a shoe has a red color variant, it can be used to create other color variant, such as a black color variant. However, it cannot be used to create a size variant.

Procedure

  1. Load attribute dictionary attributes and their allowed values.
  2. Load products.
  3. Load SKUs.
  4. Load variants with attributes, using the resolveAndAssociateVariantItems configuration property to set how the catalog entry relationship is maintained.
    resolveAndAssociateVariantItems
    True = The Data load utility implicitly maintains the catalog entry relationship between a variant and its children SKUs.
    False = You explicitly load the catalog entry relationship between a variant and its children SKUs.
  5. (Optional) If you have chosen to explicitly load the catalog entry relationship between variant and SKU (resolveAndAssociateVariantItems =False), perform the load now.

    Parameters in the wc-loader-catalog-entry.xml file

    The variant is loaded using CatalogEntryMediator (the same as product or SKU), with the Type set to "Variant." Samples can be found in HCL Commerce utility docker under the directory CommerceServer90Dir/samples/DataLoad/Catalog/Variant.

    In file wc-loader-catalog-entry.xml, the mapping for the defining attribute of a variant is defined as follows.
    <!-- Variant attributes -->
    <_config:mapping xpath="CatalogEntryAttributes/Attributes[50]/Name" value="VariantAttribute_Id" valueFrom="Fixed" />
    <_config:mapping xpath="CatalogEntryAttributes/Attributes[50]/StringValue/Value" value="VariantAttribute_Id" />
    <_config:mapping xpath="CatalogEntryAttributes/Attributes[51]/Name" value="VariantAttribute_Identifier" valueFrom="Fixed" />
    <_config:mapping xpath="CatalogEntryAttributes/Attributes[51]/StringValue/Value" value="VariantAttribute_Identifier" />
    <_config:mapping xpath="CatalogEntryAttributes/Attributes[52]/Name" value="VariantAttributeValue_Id" valueFrom="Fixed" />
    <_config:mapping xpath="CatalogEntryAttributes/Attributes[52]/StringValue/Value" value="VariantAttributeValue_Id" />
    <_config:mapping xpath="CatalogEntryAttributes/Attributes[53]/Name" value="VariantAttributeValue_Identifier" valueFrom="Fixed" />
    <_config:mapping xpath="CatalogEntryAttributes/Attributes[53]/StringValue/Value" value="VariantAttributeValue_Identifier" />
    
    Where
    VariantAttribute_Id
    The primary key of the table ATTR for the variant's defining attribute. Only one of the two columns (VariantAttribute_Id and VariantAttribute_Identifier) needs to be supplied in the input data.
    VariantAttribute_Identifier
    The field IDENTIFIER of database table ATTR variant's defining attribute. Only one of the two columns (VariantAttribute_Id and VariantAttribute_Identifier) needs to be supplied in the input data.
    VariantAttributeValue_Id
    The primary key of the table ATTRVAL for the variant's defining attribute value. Only one of the two columns (VariantAttributeValue_Id and VariantAttributeValue_Identifier) needs to be supplied in the input data.
    VariantAttributeValue_Identifier
    The field IDENTIFIER of database table ATTRVAL for the variant's defining attribute value. Only one of the two columns (VariantAttributeValue_Id and VariantAttributeValue_Identifier) needs to be supplied in the input data.
    A variant should have one and only one defining attribute/value pair. All variants under the same parent product should have same defining attribute but different value.
    Restriction: Some attributes have a large number of predefined values. If you choose as your defining attribute a predefined value that is not used by an actual SKU, then the variant will not function, despite potentially being visible in the storefront.
    And in the section of CatalogEntryMediator configuration:      
    <_config:BusinessObjectMediator className="com.ibm.commerce.catalog.dataload.mediator.CatalogEntryMediator" componentId="com.ibm.commerce.catalog" > 
    Two configuration properties are available:        
    <_config:property name="resolveAndAssociateParentVariants" value= "false" />
       <_config:property name="validateParentProductDefiningAttributes" value= "false" />

    The property resolveAndAssociateVariantItems determines whether to automatically maintain the relationship between the variant and the SKU. The property validateParentProductDefiningAttributes determines whether to perform validation on the defining attribute of the variant, for example, if there is an existing variant under the same product with the same attribute / attribute value pair.  Turning off this flag can enhance data load performance, on the condition that data integrity is ensured elsewhere. The file wc-dataload-catalog-entry-variant.xml is the main control file to load variants, and the file CatalogEntries-variant.csv is the sample input data in CSV format.

    Loading variants using a .csv file

    You can use the sample CatalogEntries-variant.csv file to load variants. The file has the format CatalogEntry,,,,,,,,,,,. There are three parameters specific to product variants.

    PartNumber,Type,ParentPartNumber,Sequence,ParentGroupIdentifier,Hide,
    Name,ShortDescription,LongDescription,VariantAttribute_Identifier,VariantAttributeValue_Identifier,Delete
    Where the new parameters are:
    Hide
    This flag indicates whether to hide this catalog entry from search and browsing in the storefront. The entry still exists and can be worked with, but does not show up in the store.
    Values: 0=Show, 1=Hide
    VariantAttribute_Id
    Specifies the variant's defining attribute Id. This is the primary key of the database table ATTRVAL. All variants of the same parent product have the same VariantAttribute_Identifier.
    VariantAttributeValue_Identifier
    Specifies the variant's defining attribute identifier in database table ATTR. Variants of the same parent product must have different VariantAttributeValue_Identifier values.
    For example, a sample entry could be:
    Cords-Black,Variant,Cords,1,Pants,1,Men's corduroy pants - Black,
    Men's corduroy pants - Black,"Fabric 50% cotton, 50% polyester.",CordsColor,Black,0

    Load catalog entry relationship between a variant and its children SKUs

    The catalog entry relationship between a variant and its children SKUs is loaded using CatalogEntryRelationshipMediator. Samples can be found in WC utility docker under the directory CommerceServer90Dir/samples/DataLoad/Catalog/Variant.

    The file wc-loader-catalog-entry-relationship.xml defines the data mapping and configures the mediator.

    The file wc-dataload-catalog-entry-relationship.xml is the main control file to run data load.

    The file CatalogEntryRelationship-variant-item.csv is the sample input data in CSV format.

    Load the relationship between SKU and attribute dictionary attribute

    When loading the relationship between SKU and attribute dictionary attribute, it implicitly changes the parent-child relationship between variants and SKUs. In this case, if you turn on the configuration property resolveAndAssociateParentVariants, the data load utility will automatically maintain the relationship between variants and SKUs.

    Samples can be found in WC utility docker under the directory CommerceServer90Dir/samples/DataLoad/Catalog/AttributeDictionaryAttribute.

    In the configuration file wc-loader-catalog-entry-AD-attribute-relationship.xml, a configuration property named resolveAndAssociateVariantItems is found. This property defaults to false.
    <_config:BusinessObjectMediator className="com.ibm.commerce.catalog.dataload.mediator.CatalogEntryAttributeDictionaryAttributeMediator" 
               componentId="com.ibm.commerce.catalog" >
            ...
            <_config:property name="resolveAndAssociateVariantItems" value="false" />
         </_config:BusinessObjectMediator>