Skip to main content

ImportParser

ImportParser

Validates and parses CSV files into a data structure which can then be used to created new entities. This is used internally by the Importer.

Signature
class ImportParser {
parseProducts(input: string | Stream, mainLanguage: LanguageCode = this.configService.defaultLanguageCode) => Promise<ParseResult<ParsedProductWithVariants>>;
}

parseProducts

method
(input: string | Stream, mainLanguage: LanguageCode = this.configService.defaultLanguageCode) => Promise<ParseResult<ParsedProductWithVariants>>

Parses the contents of the product import CSV file and returns a data structure which can then be used to populate Vendure using the FastImporterService.

ParsedOptionGroup

The intermediate representation of an OptionGroup after it has been parsed by the ImportParser.

Signature
interface ParsedOptionGroup {
translations: Array<{
languageCode: LanguageCode;
name: string;
values: string[];
}>;
}

translations

property
Array<{ languageCode: LanguageCode; name: string; values: string[]; }>

ParsedFacet

The intermediate representation of a Facet after it has been parsed by the ImportParser.

Signature
interface ParsedFacet {
translations: Array<{
languageCode: LanguageCode;
facet: string;
value: string;
}>;
}

translations

property
Array<{ languageCode: LanguageCode; facet: string; value: string; }>

ParsedProductVariant

The intermediate representation of a ProductVariant after it has been parsed by the ImportParser.

Signature
interface ParsedProductVariant {
sku: string;
price: number;
taxCategory: string;
stockOnHand: number;
trackInventory: GlobalFlag;
assetPaths: string[];
facets: ParsedFacet[];
translations: Array<{
languageCode: LanguageCode;
optionValues: string[];
customFields: {
[name: string]: string;
};
}>;
}

sku

property
string

price

property
number

taxCategory

property
string

stockOnHand

property
number

trackInventory

property
GlobalFlag

assetPaths

property
string[]

facets

property

translations

property
Array<{ languageCode: LanguageCode; optionValues: string[]; customFields: { [name: string]: string; }; }>

ParsedProduct

The intermediate representation of a Product after it has been parsed by the ImportParser.

Signature
interface ParsedProduct {
assetPaths: string[];
optionGroups: ParsedOptionGroup[];
facets: ParsedFacet[];
translations: Array<{
languageCode: LanguageCode;
name: string;
slug: string;
description: string;
customFields: {
[name: string]: string;
};
}>;
}

assetPaths

property
string[]

optionGroups

facets

property

translations

property
Array<{ languageCode: LanguageCode; name: string; slug: string; description: string; customFields: { [name: string]: string; }; }>

ParsedProductWithVariants

The data structure into which an import CSV file is parsed by the ImportParser parseProducts() method.

Signature
interface ParsedProductWithVariants {
product: ParsedProduct;
variants: ParsedProductVariant[];
}

product

variants

ParseResult

The result returned by the ImportParser parseProducts() method.

Signature
interface ParseResult<T> {
results: T[];
errors: string[];
processed: number;
}

results

property
T[]

errors

property
string[]

processed

property
number