ProductSetRepository
extends ApiRepository
in package
Front repository that reads through the Api bridge and uses the query cache when the service has it enabled (`cache.config.enabledServices`).
This is the deliberate opposite of ApiRepository: the front end only displays data, so a 5 minute old number is at most cosmetic, whereas the admin reads it into a form that is written back to the DB.
->useCache(false) on the query object overrides the policy for one query; it travels
to the payload as ApiBridge::PARAM_USE_CACHE.
IMPORTANT: null is passed on as null (no opinion), not as true. If this layer
substituted true, it would override QueryCacheContext, and
reads through a front manager inside an admin request (AssetManager, ThemeManager,
UserManager) would still be served from the cache. The true default therefore lives
in the bridge.
Table of Contents
Properties
- $apiEndpoint : string
- Api presenter path (e.g. `api/system/page`); set by each concrete repository.
- $bridge : ApiBridge
Methods
- __construct() : mixed
-
fetchAvailability()
: array<int, array{availableSets: ?int, inStock: bool, deliveryDays: ?int, labelWarehouseId: ?int, infoText: ?string, attributeClass: ?string, unmappedVariantIds: list
, unresolvedSetIds: list , inactiveSetIds: list }> - Returns set availability (one bridge round trip for N sets: {@see \App\UI\Api\Eshop\Models\Managers\ProductSetManager::getAvailabilities()}, bundle decomposition through `SetCompositionService::decomposeEach()`).
- fetchCurrentPrices() : array<int, array{price: string, originalPrice: string, points: int, fromAmount: int, currencyId: int, vat: string, withVat: bool}>
- Returns the currently valid set prices (batch, one SQL on the Api side: `PriceResolver` over the `current_prices` view).
- fetchGifts() : array<int, array{name: string, amount: int}>
- Gifts of the set for its detail (bridge action `.../gifts`, {@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionGifts()}); an Api failure gives none.
- fetchNextPriceTimes() : array<int, string>
- Returns the end of the deal for the countdown in the "Deal of the week" section: the nearest future `published_time` of the price of each given set, in one bridge round trip for all candidates ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionNextPriceTimes()}).
- fetchParameterValueCounts() : array<int, array<string|int, int>>
- Returns set counts by parameter value for the given filters; basis for the counts next to filter options. The same filters as for the list are sent; the Api resolves ids itself.
- fetchPriceDisplay() : array{paymentRegionId: int, chargeVat: bool, noteKey: ?string}
- Returns the catalog display treatment through the bridge action `.../price-display` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionPriceDisplay()}).
- find() : array<string|int, mixed>
- findAll() : array<string|int, mixed>
- findBy() : array<string|int, mixed>
- registerView() : void
- Records a set detail view into the daily statistics (upsert: a repeated view on the same day only increments). Bridge to {@see \App\UI\Api\Eshop\Presenters\ProductSetStatisticPresenter::internalActionRecordView()}.
- search() : array<string, mixed>
- Searches through the Api endpoint `search` ({@see \App\Core\Traits\Api\Presenters\SearchTrait}).
- failSoftRead() : array<string|int, mixed>
- Normalizes a bridge response to plain data; a failed envelope or a non-array gives `[]`.
- getApiCallSource() : string
- Branch marker for writes ({@see ApiBridge::PARAM_SOURCE}), read by the shared repository `SaveTrait`.
Properties
$apiEndpoint
Api presenter path (e.g. `api/system/page`); set by each concrete repository.
protected
string
$apiEndpoint
= 'api/eshop/product-set'
$bridge read-only
protected
ApiBridge
$bridge
Methods
__construct()
public
__construct(ApiBridge $bridge) : mixed
Parameters
- $bridge : ApiBridge
fetchAvailability()
Returns set availability (one bridge round trip for N sets: {@see \App\UI\Api\Eshop\Models\Managers\ProductSetManager::getAvailabilities()}, bundle decomposition through `SetCompositionService::decomposeEach()`).
public
fetchAvailability(array<string|int, int> $ids[, int|null $languageId = null ]) : array<int, array{availableSets: ?int, inStock: bool, deliveryDays: ?int, labelWarehouseId: ?int, infoText: ?string, attributeClass: ?string, unmappedVariantIds: list, unresolvedSetIds: list, inactiveSetIds: list}>
The Api side has a constant number of SQL queries. available / availableSets are never
cached; call it on every list/detail request. Same bridge action as Admin
(ProductSetPresenter::internalActionAvailability()).
Parameters
- $ids : array<string|int, int>
- $languageId : int|null = null
Return values
array<int, array{availableSets: ?int, inStock: bool, deliveryDays: ?int, labelWarehouseId: ?int, infoText: ?string, attributeClass: ?string, unmappedVariantIds: listfetchCurrentPrices()
Returns the currently valid set prices (batch, one SQL on the Api side: `PriceResolver` over the `current_prices` view).
public
fetchCurrentPrices(array<string|int, int> $ids[, int|null $userGroupId = null ][, int|null $currencyId = null ][, int $amount = 1 ][, int|null $paymentRegionId = null ]) : array<int, array{price: string, originalPrice: string, points: int, fromAmount: int, currencyId: int, vat: string, withVat: bool}>
The front list/detail must always take the price from here, never from the denormalized
ProductSet::$price (only a sort key). Same bridge action as Admin
(ProductSetPresenter::internalActionCurrentPrices()).
price / originalPrice are the base without VAT; the row also carries vat = display
rate of the VAT engine in percent and withVat = whether it should be added at all. The
display price is computed by PriceDisplayHelper.
Parameters
- $ids : array<string|int, int>
- $userGroupId : int|null = null
- $currencyId : int|null = null
- $amount : int = 1
- $paymentRegionId : int|null = null
Return values
array<int, array{price: string, originalPrice: string, points: int, fromAmount: int, currencyId: int, vat: string, withVat: bool}>fetchGifts()
Gifts of the set for its detail (bridge action `.../gifts`, {@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionGifts()}); an Api failure gives none.
public
fetchGifts(int $setId[, int|null $languageId = null ]) : array<int, array{name: string, amount: int}>
Parameters
- $setId : int
- $languageId : int|null = null
Return values
array<int, array{name: string, amount: int}>fetchNextPriceTimes()
Returns the end of the deal for the countdown in the "Deal of the week" section: the nearest future `published_time` of the price of each given set, in one bridge round trip for all candidates ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionNextPriceTimes()}).
public
fetchNextPriceTimes(array<string|int, int> $ids[, int|null $currencyId = null ]) : array<int, string>
A set without a scheduled future price (in the given currency) is absent from the array.
Parameters
- $ids : array<string|int, int>
- $currencyId : int|null = null
Return values
array<int, string> —setId => nearest future published_time
fetchParameterValueCounts()
Returns set counts by parameter value for the given filters; basis for the counts next to filter options. The same filters as for the list are sent; the Api resolves ids itself.
public
fetchParameterValueCounts(array<int, object> $filters) : array<int, array<string|int, int>>
Parameters
- $filters : array<int, object>
Return values
array<int, array<string|int, int>> —parameterId => [value => count]
fetchPriceDisplay()
Returns the catalog display treatment through the bridge action `.../price-display` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionPriceDisplay()}).
public
fetchPriceDisplay([int|null $paymentRegionId = null ]) : array{paymentRegionId: int, chargeVat: bool, noteKey: ?string}
Seller and rate go live through TaxManager on the
Api side; the front end must not touch the engine or the Invoicer tables, hence the bridge.
sellers.show_prices_with_vat is no longer read (a VAT payer always shows the price with VAT).
IMPORTANT: do not call .../defaults; that action is admin-only (a guest has allowed = 0).
Parameters
- $paymentRegionId : int|null = null
Return values
array{paymentRegionId: int, chargeVat: bool, noteKey: ?string}find()
public
find(int $id[, string|array<string|int, mixed> $includes = [] ][, bool|null $useCache = null ]) : array<string|int, mixed>
Parameters
- $id : int
- $includes : string|array<string|int, mixed> = []
- $useCache : bool|null = null
Return values
array<string|int, mixed>findAll()
public
findAll([array<string|int, mixed>|null $filters = [] ][, array<string|int, mixed>|null $orderBys = null ][, int|null $offset = null ][, int|null $limit = null ][, array<string|int, mixed>|null $columns = null ][, bool $computeTotalCount = false ][, string|array<string|int, mixed> $includes = [] ][, bool|null $useCache = null ]) : array<string|int, mixed>
Parameters
- $filters : array<string|int, mixed>|null = []
- $orderBys : array<string|int, mixed>|null = null
- $offset : int|null = null
- $limit : int|null = null
- $columns : array<string|int, mixed>|null = null
- $computeTotalCount : bool = false
- $includes : string|array<string|int, mixed> = []
- $useCache : bool|null = null
Return values
array<string|int, mixed>findBy()
public
findBy([array<string|int, mixed>|null $filters = [] ][, string|array<string|int, mixed> $includes = [] ][, bool|null $useCache = null ]) : array<string|int, mixed>
Parameters
- $filters : array<string|int, mixed>|null = []
- $includes : string|array<string|int, mixed> = []
- $useCache : bool|null = null
Return values
array<string|int, mixed>registerView()
Records a set detail view into the daily statistics (upsert: a repeated view on the same day only increments). Bridge to {@see \App\UI\Api\Eshop\Presenters\ProductSetStatisticPresenter::internalActionRecordView()}.
public
registerView(int $id) : void
Fire-and-forget for the calling presenter: an error is silently ignored (see ProductSetManager::registerView()); tracking must not fail or slow down the detail rendering.
Parameters
- $id : int
search()
Searches through the Api endpoint `search` ({@see \App\Core\Traits\Api\Presenters\SearchTrait}).
public
search(string $search, string|null $languageAlias[, array<int, object|array<string, mixed>> $filters = [] ][, array<string, mixed>|null $orderBys = null ][, int|null $offset = null ][, int|null $limit = null ][, string|array<int, string> $includes = [] ]) : array<string, mixed>
With orderBys = null Elasticsearch sorts and paginates by relevance; with orderBys
filled (manual user choice) the DB sorts, paginates and counts over the ES id set, and a
manual order overrides the score. Returns the raw payload
{items, totalCount, _references, fromEs, highlights}.
Parameters
- $search : string
- $languageAlias : string|null
- $filters : array<int, object|array<string, mixed>> = []
-
visibility filters (ProductSetEligibilityFilters) and parameter filters (ready objects)
- $orderBys : array<string, mixed>|null = null
- $offset : int|null = null
- $limit : int|null = null
- $includes : string|array<int, string> = []
Return values
array<string, mixed> —payload, or [] on failure/DENY (fail-soft)
failSoftRead()
Normalizes a bridge response to plain data; a failed envelope or a non-array gives `[]`.
protected
failSoftRead(mixed $response, string $endpoint) : array<string|int, mixed>
NOTE: it does not log on purpose. ApiBridge::call(), which sees both the
endpoint and the caller, has already written the API_FAILSOFT source=bridge line; a second
copy would turn one failure into three lines in auth.log.
Parameters
- $response : mixed
- $endpoint : string
-
only for call readability; the log takes the endpoint from the bridge
Return values
array<string|int, mixed>getApiCallSource()
Branch marker for writes ({@see ApiBridge::PARAM_SOURCE}), read by the shared repository `SaveTrait`.
protected
getApiCallSource() : string