ImportMatcher
in package
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
Table of Contents
Constants
- LOOKUP_CHUNK : int = 100
- Cards per matching query; a compromise between query count and the size of `IN (...)`.
Properties
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
$productManager read-only
private
ProductManager
$productManager
$productSetManager read-only
private
ProductSetManager
$productSetManager
Methods
__construct()
public
__construct(ProductSetManager $productSetManager, ProductManager $productManager) : mixed
Parameters
- $productSetManager : ProductSetManager
- $productManager : ProductManager
findSets()
public
findSets(array<int, InFilter> $filters) : array<int, MatchRow>
Parameters
- $filters : array<int, InFilter>
Return values
array<int, MatchRow>loadMatches()
Fills the batch registries in the context: `matchesByKey`, `matchesByCode`, `matchesById`, `productIds`, `productLanguageIds`.
public
loadMatches(array<int, ImportProductDto> $products, ImportValidationContext $context) : void
Parameters
- $products : array<int, ImportProductDto>
- $context : ImportValidationContext
resolveMatches()
Sets matching a variant: an explicit `id` wins, otherwise the matching key by `matchBy`.
public
resolveMatches(ImportVariantDto $variant, ImportValidationContext $context) : array<int, MatchRow>
Parameters
- $variant : ImportVariantDto
- $context : ImportValidationContext
Return values
array<int, MatchRow>collectLanguageIds()
private
collectLanguageIds(iterable<string|int, object> $translations) : array<int, int>
Parameters
- $translations : iterable<string|int, object>