CoolCMS API

ImportMatcher
in package

FinalYes

Matching of variant code → set → variant → card, shared by validator and executor.

One query for all matching keys of a batch (+ one for explicit set ids and one for explicit card ids). Soft-deleted sets are deliberately not filtered out: ProductSet.code is unique also against them (ProductSetManager beforeSave checks the code regardless of deleted), so a "free" code would be a lie.

IMPORTANT: it calls Api managers that clear their EntityManager (clearDoctrine), so the results are scalar rows only (id, code, EAN, type, text languages), never held entities.

Codes are always queried into matchesByCode (also with matchBy=ean, where EAN is the matching key): a code is unique, so the validator must see that the code of an item belongs to another set, or that renaming via <variant id> would collide. typeId reveals a bundle or a set without a card; languageIds (languages of existing texts of the set or card) decide that a new translation row needs a name.

Tags
phpstan-type

MatchRow array{setId: int, productId: int|null, variantId: int|null, deleted: bool, code: string, ean: string|null, typeId: int, languageIds: list}

Table of Contents

Constants

LOOKUP_CHUNK  : int = 100
Cards per matching query; a compromise between query count and the size of `IN (...)`.

Properties

$productManager  : ProductManager
$productSetManager  : ProductSetManager

Methods

__construct()  : mixed
findSets()  : array<int, MatchRow>
loadMatches()  : void
Fills the batch registries in the context: `matchesByKey`, `matchesByCode`, `matchesById`, `productIds`, `productLanguageIds`.
resolveMatches()  : array<int, MatchRow>
Sets matching a variant: an explicit `id` wins, otherwise the matching key by `matchBy`.
collectLanguageIds()  : array<int, int>

Constants

LOOKUP_CHUNK

Cards per matching query; a compromise between query count and the size of `IN (...)`.

public int LOOKUP_CHUNK = 100

Properties

Methods

findSets()

public findSets(array<int, InFilter> $filters) : array<int, MatchRow>
Parameters
$filters : array<int, InFilter>
Return values
array<int, MatchRow>

collectLanguageIds()

private collectLanguageIds(iterable<string|int, object> $translations) : array<int, int>
Parameters
$translations : iterable<string|int, object>
Return values
array<int, int>
On this page

Search results