ProductImportManager
extends Manager
in package
Thin facade manager for the product import job.
CRUD goes through the generic traits of the base manager (bridge to the Api
ProductImportPresenter). setState() is a
dedicated bridge action outside the generic save (like FeedManager::saveParameterTree()),
used by the cancel button (transition to cancelled). The remaining actions are
validate(), getValidationReport(), enqueue(), runNow() and getRunStatus().
Tags
Table of Contents
Properties
- $service : TService
- Manager service; subclasses narrow the type (`@property` in the Api/Admin/Front manager).
- $appContext : AppContext
- $cacheTagInvalidator : CacheTagInvalidator|null
- Post-commit invalidator of the wire-payload query cache (tag bump per entity class).
- $languageContext : LanguageContext|null
- $paramsConfig : Config|null
- Neon parameters (`%params%`: server paths and directories), set by the decorator (`decorators.neon`) like `setAppContext()`.
- $presenterContext : PresenterContext
- $settingContext : SettingContext
Methods
- __construct() : mixed
- delete() : Result
- deleteAll() : Result
- enqueue() : array{success: bool, message: ?string, data: mixed, code: ?int}
- Queues the job; the cron `/cron/eshop/product-import/run` picks it up within a minute.
- export() : array{success: bool, message: ?string, data: mixed, code: ?int}
- Exports the catalog in the import format, without a job.
- find() : SingleQuery<string|int, T>
- Finds one entity by id (returns a `SingleQuery` object).
- findAll() : Query<string|int, T>
- Finds all entities (returns a `Query` object).
- findBy() : SingleQuery<string|int, T>
- Finds one entity by filters (returns a `SingleQuery` object).
- getAppContext() : AppContext
- getLanguageContext() : LanguageContext|null
- getPresenterContext() : PresenterContext
- getRunStatus() : array{success: bool, message: ?string, data: mixed, code: ?int}
- Returns the run progress for polling: counters, state and the last N errors of the execution log.
- getSettingContext() : SettingContext
- getSettings() : array<int, array<string, mixed>>
- getStatistics() : array{success: bool, message: ?string, data: mixed, code: ?int}
- Returns the run summary for a period plus the last N jobs. `$from` and `$to` are `Y-m-d` (`null` lets the Api choose the default range).
- getTotalCount() : int|null
- Returns the total count of the last `findAll()` of this manager's service, computed only when the query asked for it (`findAll(..., computeTotalCount: true)`); otherwise the last stored value.
- getValidationReport() : array{success: bool, message: ?string, data: mixed, code: ?int}
- Returns the summary plus one page of the row log (`phase` is `validate` for the dry run or `execute` for the real run). The job decides the log path, not the request.
- initializeAllContexts() : void
- runNow() : array{success: bool, message: ?string, data: mixed, code: ?int}
- Runs the job immediately (up to 200 items) synchronously in the admin request. The calling trait holds the lock against a concurrent cron run (like the feed edit `GenerateTrait`).
- save() : Result
- setAppContext() : $this
- setCacheTagInvalidator() : static
- setLanguageContext() : $this
- setParamsConfig() : static
- setPresenterContext() : $this
- setSettingContext() : $this
- setState() : array{success: bool, message: ?string, data: mixed, code: ?int}
- updateColumn() : Result
- updateColumns() : Result
- validate() : array{success: bool, message: ?string, data: mixed, code: ?int}
- Runs the dry-run validation: writes nothing to the catalog, only changes the job state and counters.
- bumpCacheTags() : void
- Bumps cache tags for the entity after commit: its class, the owned-cascade classes from metadata and the optional `additionalCacheTags()` of the manager.
- bumpCacheTagsExplicit() : void
- Bumps the given classes explicitly (raw-DBAL paths with a cross-entity effect).
- bumpCacheTagsForClass() : void
- Bumps cache tags by class name when there is no instance (bulk delete, `updateColumns()`, raw DBAL, tree operations).
- classCacheTags() : array<string|int, string>
- Returns extra tags for a bump that has no entity, typically tree operations ({@see \App\Core\Traits\Api\Models\Managers\TreeTrait::treeTransaction()}) that rewrite `lft`/`rgt` on many rows.
- getService() : TService
- Returns the service for the traits.
- getImportService() : ProductImportService
Properties
$service
Manager service; subclasses narrow the type (`@property` in the Api/Admin/Front manager).
public
TService
$service
$appContext
protected
AppContext
$appContext
$cacheTagInvalidator
Post-commit invalidator of the wire-payload query cache (tag bump per entity class).
protected
CacheTagInvalidator|null
$cacheTagInvalidator
= null
Set by the decorator (decorators.neon) like setParamsConfig(). Nullable and
fail-open: without wiring (or without Redis) a bump is a no-op.
$languageContext
protected
LanguageContext|null
$languageContext
= NULL
$paramsConfig
Neon parameters (`%params%`: server paths and directories), set by the decorator (`decorators.neon`) like `setAppContext()`.
protected
Config|null
$paramsConfig
= null
Write logic (asset directories) reads paths from here, not from getSettings() or the
setting context, which may be filled by the client without server paths. The property
cannot be named $config: it collides with the promoted $config in some managers.
$presenterContext
protected
PresenterContext
$presenterContext
$settingContext
protected
SettingContext
$settingContext
Methods
__construct()
public
__construct(ProductImportService $service) : mixed
Parameters
- $service : ProductImportService
delete()
public
delete(int|array<string|int, mixed> $id) : Result
Parameters
- $id : int|array<string|int, mixed>
Return values
ResultdeleteAll()
public
deleteAll([array<string|int, mixed> $filters = [] ]) : Result
Parameters
- $filters : array<string|int, mixed> = []
Return values
Resultenqueue()
Queues the job; the cron `/cron/eshop/product-import/run` picks it up within a minute.
public
enqueue(int $id) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $id : int
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}export()
Exports the catalog in the import format, without a job.
public
export(array<int, int> $productIds, array<int, int> $productSetIds, array<int, string> $languages, bool $includeIds, array<int, string> $sections) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $productIds : array<int, int>
- $productSetIds : array<int, int>
- $languages : array<int, string>
- $includeIds : bool
- $sections : array<int, string>
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}find()
Finds one entity by id (returns a `SingleQuery` object).
public
find(int $id[, string|array<string|int, mixed> $includes = [] ]) : SingleQuery<string|int, T>
Parameters
- $id : int
-
entity id
- $includes : string|array<string|int, mixed> = []
-
relations to load (
['translations', 'routes']or'*'for all)
Return values
SingleQuery<string|int, T>findAll()
Finds all entities (returns a `Query` object).
public
findAll([array<string|int, mixed>|null $filters = [] ][, array<string|int, mixed>|null $orderBy = null ][, int|null $offset = null ][, int|null $limit = null ][, array<string|int, mixed>|null $columns = null ][, string|array<string|int, mixed> $includes = [] ][, bool $computeTotalCount = false ]) : Query<string|int, T>
Parameters
- $filters : array<string|int, mixed>|null = []
-
filters for the where conditions
- $orderBy : array<string|int, mixed>|null = null
-
ordering
['column' => 'ASC/DESC'] - $offset : int|null = null
-
offset for pagination
- $limit : int|null = null
-
result limit
- $columns : array<string|int, mixed>|null = null
-
specific columns to load
- $includes : string|array<string|int, mixed> = []
-
relations to load (
['translations', 'routes.translations']or'*'for all) - $computeTotalCount : bool = false
-
whether to compute the total count for pagination
Return values
Query<string|int, T>findBy()
Finds one entity by filters (returns a `SingleQuery` object).
public
findBy([array<string|int, mixed> $filters = [] ][, string|array<string|int, mixed> $includes = [] ]) : SingleQuery<string|int, T>
Parameters
- $filters : array<string|int, mixed> = []
-
filters for the where conditions
- $includes : string|array<string|int, mixed> = []
-
relations to load (
['translations', 'routes']or'*'for all)
Return values
SingleQuery<string|int, T>getAppContext()
public
getAppContext() : AppContext
Return values
AppContextgetLanguageContext()
public
getLanguageContext() : LanguageContext|null
Return values
LanguageContext|nullgetPresenterContext()
public
getPresenterContext() : PresenterContext
Return values
PresenterContextgetRunStatus()
Returns the run progress for polling: counters, state and the last N errors of the execution log.
public
getRunStatus(int $id) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $id : int
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}getSettingContext()
public
getSettingContext() : SettingContext
Return values
SettingContextgetSettings()
public
getSettings() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>getStatistics()
Returns the run summary for a period plus the last N jobs. `$from` and `$to` are `Y-m-d` (`null` lets the Api choose the default range).
public
getStatistics(string|null $from, string|null $to, int $limit) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $from : string|null
- $to : string|null
- $limit : int
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}getTotalCount()
Returns the total count of the last `findAll()` of this manager's service, computed only when the query asked for it (`findAll(..., computeTotalCount: true)`); otherwise the last stored value.
public
getTotalCount() : int|null
Same value as Query::getTotalCount() of that query.
Return values
int|nullgetValidationReport()
Returns the summary plus one page of the row log (`phase` is `validate` for the dry run or `execute` for the real run). The job decides the log path, not the request.
public
getValidationReport(int $id[, int $page = 1 ][, int $perPage = 50 ][, string|null $level = null ][, string $phase = 'validate' ]) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $id : int
- $page : int = 1
- $perPage : int = 50
- $level : string|null = null
- $phase : string = 'validate'
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}initializeAllContexts()
public
initializeAllContexts() : void
runNow()
Runs the job immediately (up to 200 items) synchronously in the admin request. The calling trait holds the lock against a concurrent cron run (like the feed edit `GenerateTrait`).
public
runNow(int $id) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $id : int
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}save()
public
save(BaseEntity $entity[, array<string, mixed> $meta = [] ]) : Result
Parameters
- $entity : BaseEntity
- $meta : array<string, mixed> = []
Return values
ResultsetAppContext()
public
setAppContext(AppContext $appContext) : $this
Parameters
- $appContext : AppContext
Return values
$thissetCacheTagInvalidator()
public
setCacheTagInvalidator(CacheTagInvalidator $cacheTagInvalidator) : static
Parameters
- $cacheTagInvalidator : CacheTagInvalidator
Return values
staticsetLanguageContext()
public
setLanguageContext(LanguageContext|null $languageContext) : $this
Parameters
- $languageContext : LanguageContext|null
Return values
$thissetParamsConfig()
public
setParamsConfig(Config $paramsConfig) : static
Parameters
- $paramsConfig : Config
Return values
staticsetPresenterContext()
public
setPresenterContext(PresenterContext $presenterContext) : $this
Parameters
- $presenterContext : PresenterContext
Return values
$thissetSettingContext()
public
setSettingContext(SettingContext $settingContext) : $this
Parameters
- $settingContext : SettingContext
Return values
$thissetState()
public
setState(int $id, string $state) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $id : int
- $state : string
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}updateColumn()
public
updateColumn(int|array<string|int, mixed> $entityId, string $property, mixed $value) : Result
Parameters
- $entityId : int|array<string|int, mixed>
-
id, or a list of ids / composite-id arrays
- $property : string
- $value : mixed
Return values
ResultupdateColumns()
public
updateColumns(int|array<string|int, mixed> $entityId, array<string, mixed> $values) : Result
Parameters
- $entityId : int|array<string|int, mixed>
-
id, or a list of ids / composite-id arrays
- $values : array<string, mixed>
-
property name => new value
Return values
Resultvalidate()
Runs the dry-run validation: writes nothing to the catalog, only changes the job state and counters.
public
validate(int $id) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $id : int
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}bumpCacheTags()
Bumps cache tags for the entity after commit: its class, the owned-cascade classes from metadata and the optional `additionalCacheTags()` of the manager.
protected
bumpCacheTags(object $entity) : void
Fail-open (the invalidator swallows exceptions). Called from the manager Save/Delete/Tree traits after the commit.
Parameters
- $entity : object
bumpCacheTagsExplicit()
Bumps the given classes explicitly (raw-DBAL paths with a cross-entity effect).
protected
bumpCacheTagsExplicit(array<string|int, string> $classes) : void
Parameters
- $classes : array<string|int, string>
bumpCacheTagsForClass()
Bumps cache tags by class name when there is no instance (bulk delete, `updateColumns()`, raw DBAL, tree operations).
protected
bumpCacheTagsForClass(class-string $rootClass[, array<string|int, string> $extraTags = [] ]) : void
Bumps the root class and its owned-cascade classes.
Parameters
- $rootClass : class-string
- $extraTags : array<string|int, string> = []
classCacheTags()
Returns extra tags for a bump that has no entity, typically tree operations ({@see \App\Core\Traits\Api\Models\Managers\TreeTrait::treeTransaction()}) that rewrite `lft`/`rgt` on many rows.
protected
classCacheTags() : array<string|int, string>
IMPORTANT: additionalCacheTags(object) receives an entity, so a class-level bump cannot
use it; without this hook a delete would lose the cross-entity tag (Comment to
CommentThread). A manager whose cross-entity tag does not depend on a particular
entity returns it here.
NOTE: unlike additionalCacheTags(), this hook is declared (with an empty default)
instead of being an opt-in through method_exists(); method_exists() is always true in
a manager that has the method, which phpstan reports as alreadyNarrowedType.
Return values
array<string|int, string>getService()
Returns the service for the traits.
protected
getService() : TService
Return values
TServicegetImportService()
private
getImportService() : ProductImportService