Documentation Home

Import Specifications

The Import Specification basically provides the Importer module with a mapping of field name (from the import file) to the corresponding database table/field name (see Import Field below). The system ships with default specifications for Product (product/sku), Category, Customer, and CustomerAddress. These specifications are intended to be overridden for your specific needs.

Default Import Specifications

  • DefaultCategoryImportSpecification
  • DefaultProductImportSpecification
  • DefaultOrderImportSpecification
  • DefaultCustomerImportSpecification
  • DefaultCustomerAddressImportSpecification

Import Fields

In conjunction with the Specification, the Fields class is used to specify the table, fields, data type, and other relevant persistence metadata. When you customize your Specification, you will be using import Fields as part of that specification.

Example

This is an example of extension of import specification. In the example below SOME_FIELD is defined for category and added to the Config Map. Assumption made here is that the field/column defined is in the same table defined by CategoryField. For Extended entity with columns in joined tables, see Extension Guide

@Component("CustomCategorySpec")
public class CustomCategorySpec extends DefaultCategoryImportSpecification {

    public static CategoryField SOME_FIELD = new CategoryField("COLUMN_NAME", FieldDataType.STRING);

    protected void initializeFieldConfigMap() {

        super.initializeFieldConfigMap();
        LinkedHashMap<String, ImportFieldConfig> fcMap = getFieldConfigMap();
        fcMap.put("SOME_FIELD_HEADER", new ImportFieldConfig(SOME_FIELD, RequiredIndicator.FALSE, null));
    }
}

Then override the bean in the Core Config to replace the Default Category Import Specification.

    @Bean
    public CustomCategorySpec blDefaultCategoryImportSpecification(CustomCategorySpec CustomCategorySpec) {
        return CustomCategorySpec;
    }

Alternatively Custom Category specification can be added to the list instead of replacing the default specification. Simply merge it to the list of Import Specifications in core config.

    @Merge("blImportSpecifications")
    public List<ImportSpecification> mergeImportSpecs(CustomCategorySpec CustomCategorySpec) {
        //Give it a different name
        CustomCategorySpec.setDisplayName("MyCategories");
        return Arrays.asList(CustomCategorySpec);
    }