Adventure Documentation

ProductFilterControllerNew extends ProductCommonController
in package

Controller for managing product filtering functionality.

This controller processes and filters products based on various criteria including:

  • Categories and brands
  • Price ranges
  • Sale and new product status
  • Variant attributes and custom data fields
  • Search queries

The filtering process uses a two-phase approach:

  1. Filter cached products and calculate counts for each filter option
  2. Return the filter map with available options and their counts

Filter options are only counted when a product matches ALL OTHER active filters, ensuring accurate "available options" counts in the UI.

Tags

Table of Contents

__construct()  : mixed
Initializes the product filter controller.
filterCachedProduct()  : bool
Filters a cached product and updates filter map counts.
filterCustomDataGroups()  : array<string|int, mixed>
Retrieves configured custom data filter groups.
filterVariantGroups()  : array<string|int, mixed>
Retrieves configured variant filter groups.
getFilterMap()  : array<string|int, mixed>|null
Returns the complete filter map with processed data.
getPaymentOptions()  : mixed
Legacy, do not use this method
getUnitTitle()  : string
Get the title of a product entity

Methods

__construct()

Initializes the product filter controller.

public __construct([bool $parseUriParameters = false ][, bool|array<string|int, mixed> $filterData = false ]) : mixed

Sets up access checks, processes filter data, and initializes the filter map with configured filter groups (categories, brands, variants, custom data).

Parameters
$parseUriParameters : bool = false

Whether to parse URI parameters (inherited from parent)

$filterData : bool|array<string|int, mixed> = false

Filter data array containing params, entries, and configuration Expected structure:

  • 'params': ['filter' => [], 'languageIso' => '', 'categoryId' => 0]
  • 'dateCreated': Product creation dates
  • 'dateCreatedTimestamp': Product creation timestamps
  • 'vatGroups': VAT group IDs
  • 'discountGroups': Discount group IDs
  • 'itemNumbers': Product item numbers
  • 'eanNumbers': Product EAN numbers
  • 'sorting': Product sorting values
Tags
Return values
mixed

filterCachedProduct()

Filters a cached product and updates filter map counts.

public filterCachedProduct(object|null $cachedProduct, int $key) : bool

This is the main filtering method called for each product. It:

  1. Validates product basic requirements (enabled, has title)
  2. Calculates product price and sale status
  3. Populates product data from cache
  4. Determines which filter groups the product matches
  5. Updates filter map with counts (only for products matching other filters)
  6. Returns whether the product matches ALL active filters

Products are hard-filtered immediately if 'sale' is a base URL parameter (not a filter input).

Parameters
$cachedProduct : object|null

Cached product object

$key : int

Index in the entries array for this product

Tags
Return values
bool

True if product matches all active filters and should be included in results

filterCustomDataGroups()

Retrieves configured custom data filter groups.

public filterCustomDataGroups(array<string|int, mixed> $params) : array<string|int, mixed>

Reads custom data configuration from settings (comma-separated list of "id_mode_visibility") and creates FilterCustomDataGroup objects for each configured field.

Custom data groups are filtered by category visibility if a category ID is provided. Preloads translations for custom data titles in the specified language.

Configuration format: "customDataId_mode_visibility,..."

  • customDataId: Numeric custom data field ID
  • mode: "true" (checkbox), "slider" (range), or other mode identifier
  • visibility: Optional category visibility constraint

Mode conversions:

  • "true" -> "checkbox"
  • "slider" -> "range"
  • other values passed through
Parameters
$params : array<string|int, mixed>

Parameters containing 'categoryId' and 'languageIso'

Tags
Return values
array<string|int, mixed>

Array of FilterCustomDataGroup objects keyed by custom data ID

filterVariantGroups()

Retrieves configured variant filter groups.

public filterVariantGroups(array<string|int, mixed> $params) : array<string|int, mixed>

Reads variant configuration from settings (comma-separated list of "id_mode_visibility") and creates FilterVariantGroup objects for each configured variant.

Variants are filtered by category visibility if a category ID is provided. Preloads translations for variant titles in the specified language.

Configuration format: "variantId_mode_visibility,..."

  • variantId: Numeric variant attribute ID
  • mode: "true" (checkbox), "range", or other mode identifier
  • visibility: Optional category visibility constraint
Parameters
$params : array<string|int, mixed>

Parameters containing 'categoryId' and 'languageIso'

Tags
Return values
array<string|int, mixed>

Array of FilterVariantGroup objects keyed by variant ID

getFilterMap()

Returns the complete filter map with processed data.

public getFilterMap([array<string|int, mixed> $filterParams = [] ]) : array<string|int, mixed>|null

Performs final processing on the filter map:

  • Filters out invalid categories
  • Processes data groups (calculates ranges or sorts select options)
  • Processes and sorts brand and category options
  • Calculates price ranges
  • Adds counts to titles and marks disabled options

Returns null if filtering is not enabled.

Parameters
$filterParams : array<string|int, mixed> = []

Optional parameters:

  • 'orderByDisabled': Whether to sort disabled options last (default: false)
Tags
Return values
array<string|int, mixed>|null

The complete filter map structure or null if filtering disabled

getPaymentOptions()

Legacy, do not use this method

public getPaymentOptions(mixed $Price) : mixed
Parameters
$Price : mixed
Tags
Return values
mixed

getUnitTitle()

Get the title of a product entity

public getUnitTitle(mixed $UnitId[, mixed $LanguageIso = null ]) : string
Parameters
$UnitId : mixed
$LanguageIso : mixed = null
Tags
Return values
string

        

Search results