Skip to main content

FastImporterService

FastImporterService

A service to import entities into the database. This replaces the regular create methods of the service layer with faster versions which skip much of the defensive checks and other DB calls which are not needed when running an import. It also does not publish any events, so e.g. will not trigger search index jobs.

In testing, the use of the FastImporterService approximately doubled the speed of bulk imports.

Signature
class FastImporterService {
initialize(channel?: Channel) => ;
createProduct(input: CreateProductInput) => Promise<ID>;
createProductOptionGroup(input: CreateProductOptionGroupInput) => Promise<ID>;
createProductOption(input: CreateProductOptionInput) => Promise<ID>;
addOptionGroupToProduct(productId: ID, optionGroupId: ID) => ;
createProductVariant(input: CreateProductVariantInput) => Promise<ID>;
}

initialize

method
(channel?: Channel) =>

This should be called prior to any of the import methods, as it establishes the default Channel as well as the context in which the new entities will be created.

Passing a channel argument means that Products and ProductVariants will be assigned to that Channel.

createProduct

method
(input: CreateProductInput) => Promise<ID>

createProductOptionGroup

method
(input: CreateProductOptionGroupInput) => Promise<ID>

createProductOption

method
(input: CreateProductOptionInput) => Promise<ID>

addOptionGroupToProduct

method
(productId: ID, optionGroupId: ID) =>

createProductVariant

method
(input: CreateProductVariantInput) => Promise<ID>