CoolCMS API

ImportCodebooks
in package

FinalYes

Import code lists (matching of names and keys) as **id maps, not entities**: loaded once per run ({@see ImportCodebookLoader}) and then only queried in memory.

IMPORTANT: Doctrine entities are deliberately not held here. Validation and the executor run over batches with em->clear() between them, and a held entity would become a detached ghost after the clear; an id always survives it.

Matching is case-insensitive where a name is matched (parameter option text is ParameterText.name, case-insensitive); keys (Parameter.key, Unit.code, Warehouse.code, Currency.key) are normalized the same way, so the import does not break on letter case in the supplier's export.

Table of Contents

Properties

$categoriesByHref  : array<string|int, mixed>
$categoriesByPath  : array<string|int, mixed>
$currencies  : array<string|int, mixed>
$defaultLanguageId  : int
$defaultUserGroupId  : int
$defaultWarehouseId  : int|null
$languages  : array<string|int, mixed>
$parameterOptionsByKey  : array<string|int, mixed>
$parameterOptionsByName  : array<string|int, mixed>
$parameters  : array<string|int, mixed>
$producers  : array<string|int, mixed>
$productStates  : array<string|int, mixed>
$productTags  : array<string|int, mixed>
$productTypes  : array<string|int, mixed>
$unitCodes  : array<string|int, mixed>
$units  : array<string|int, mixed>
$vatPercents  : array<string|int, mixed>
$vats  : array<string|int, mixed>
$warehouses  : array<string|int, mixed>

Methods

__construct()  : mixed
findCategoryIdByHref()  : int|null
findCategoryIdByPath()  : int|null
Path of names separated by `/`; spaces around the separator are optional (`" / "` is accepted).
findLanguageId()  : int|null
findParameter()  : array{id: int, type: int|null, hasOptions: bool}|null
findParameterOptionId()  : int|null
findVatPercents()  : string|null
VAT rate of the set (`Vat.percents`) for deriving the price without VAT from `<amountWithVat>`.
normalize()  : string
Single normalized key form; without it `CZK` and `czk` would miss each other.
normalizePath()  : string
normalizePercents()  : string
`Vat.percents` is decimal(5,2): `21`, `21.0` and `21,00` must hit the same row.
registerCategory()  : void
Called by the executor after auto-creating a category by `path`; `href` is optional (default language).
registerParameterOption()  : void
Called by the writer after auto-creating a parameter option (`autoCreateOptions`); later cards of the file with the same new value find it instead of creating a duplicate.
registerProducer()  : void
Called by the executor after auto-creating a producer; later cards of the file then match it.

Properties

$parameterOptionsByKey

public array<string|int, mixed> $parameterOptionsByKey

$parameterOptionsByName

public array<string|int, mixed> $parameterOptionsByName

$productStates read-only

public array<string|int, mixed> $productStates

$productTypes read-only

public array<string|int, mixed> $productTypes

Methods

__construct()

public __construct(array<string, int> $languages, int $defaultLanguageId, array<string, int> $categoriesByHref, array<string, int> $categoriesByPath, array<string, int> $producers, array<string, int> $productTypes, array<string, int> $productStates, array<string, int> $productTags, array<string, int> $units, array<int, string> $unitCodes, array<string, int> $currencies, array<string, int> $vats, array<int, string> $vatPercents, array<string, array{id: int, type: int|null, hasOptions: bool}> $parameters, array<string, array<string, int>> $parameterOptionsByKey, array<string, array<string, int>> $parameterOptionsByName, array<string, int> $warehouses, int|null $defaultWarehouseId[, int $defaultUserGroupId = 0 ]) : mixed
Parameters
$languages : array<string, int>

alias (cs) => id

$defaultLanguageId : int
$categoriesByHref : array<string, int>

ProductCategoryText.href (default language) => id

$categoriesByPath : array<string, int>

path of names (elektro / apple) => id

$producers : array<string, int>

Producer.name => id

$productTypes : array<string, int>

ProductTypeText.name => id

$productStates : array<string, int>

ProductStateText.name => id

$productTags : array<string, int>

ProductTagText.name => id

$units : array<string, int>

Unit.code (normalized) => id

$unitCodes : array<int, string>

id => canonical Unit.code (denormalized ProductSet.unit is filled from the code list, not from the raw file text)

$currencies : array<string, int>

Currency.key => id

$vats : array<string, int>

Vat.percents (normalized) => id

$vatPercents : array<int, string>

id => Vat.percents (price without VAT is derived from <amountWithVat>)

$parameters : array<string, array{id: int, type: int|null, hasOptions: bool}>

Parameter.key => meta

$parameterOptionsByKey : array<string, array<string, int>>

Parameter.key => (option key => id)

$parameterOptionsByName : array<string, array<string, int>>

Parameter.key => (option name => id)

$warehouses : array<string, int>

Warehouse.code => id

$defaultWarehouseId : int|null
$defaultUserGroupId : int = 0

findCategoryIdByHref()

public findCategoryIdByHref(string $href) : int|null
Parameters
$href : string
Return values
int|null

findCategoryIdByPath()

Path of names separated by `/`; spaces around the separator are optional (`" / "` is accepted).

public findCategoryIdByPath(string $path) : int|null
Parameters
$path : string
Return values
int|null

findLanguageId()

public findLanguageId(string|null $alias) : int|null
Parameters
$alias : string|null
Return values
int|null

findParameter()

public findParameter(string $key) : array{id: int, type: int|null, hasOptions: bool}|null
Parameters
$key : string
Return values
array{id: int, type: int|null, hasOptions: bool}|null

findParameterOptionId()

public findParameterOptionId(string $parameterKey, string|null $optionKey, string|null $optionName) : int|null
Parameters
$parameterKey : string
$optionKey : string|null
$optionName : string|null
Return values
int|null

findVatPercents()

VAT rate of the set (`Vat.percents`) for deriving the price without VAT from `<amountWithVat>`.

public findVatPercents(int|null $vatId) : string|null
Parameters
$vatId : int|null
Return values
string|null

normalize()

Single normalized key form; without it `CZK` and `czk` would miss each other.

public static normalize(string $value) : string
Parameters
$value : string
Return values
string

normalizePath()

public static normalizePath(string $path) : string
Parameters
$path : string
Return values
string

normalizePercents()

`Vat.percents` is decimal(5,2): `21`, `21.0` and `21,00` must hit the same row.

public static normalizePercents(string $value) : string
Parameters
$value : string
Return values
string

registerCategory()

Called by the executor after auto-creating a category by `path`; `href` is optional (default language).

public registerCategory(string $path, string|null $href, int $id) : void
Parameters
$path : string
$href : string|null
$id : int

registerParameterOption()

Called by the writer after auto-creating a parameter option (`autoCreateOptions`); later cards of the file with the same new value find it instead of creating a duplicate.

public registerParameterOption(string $parameterKey, string|null $optionKey, string $optionName, int $id) : void
Parameters
$parameterKey : string
$optionKey : string|null
$optionName : string
$id : int

registerProducer()

Called by the executor after auto-creating a producer; later cards of the file then match it.

public registerProducer(string $name, int $id) : void
Parameters
$name : string
$id : int
On this page

Search results