Appearance
Product Browsing (Category Page)
Flow ID: CF-01 | Module(s): eshop | Complexity: High | Last Updated: 2026-11-04 — 4.129.0 resync: citations re-anchored; previous: 2026-10-19 — 4.128.0 resync: tag filter becomes one subquery per tag category (#939), more than
APP_MAX_ACTIVE_TAG_FILTERSactive tag filters answer 410 (#940), the sidebar offers only tags that leave the listing non-empty (#941), zero-product listings are cached (#666), citation refresh; previous: 2026-10-13
Business Overview
The category page is the primary product discovery experience on the storefront. When a customer navigates to a product category — either through the navigation menu, a direct link, or search — they see a paginated grid of products with interactive filtering options.
What customers experience:
- A grid of products organized by category (e.g., "Electronics", "Clothing")
- Sidebar filters to narrow results: price range, brand/vendor, tags, product attributes (size, color), and variation filters
- Sorting options: by price, popularity, newest, or custom sort keys
- Pagination to browse large catalogs — a "show N per page" selector offering 9 / 18 / 36 / 72 items (default 36), capped at a configurable ceiling (
products_list_max, default 72)
Key business behaviors:
- Browsing a parent category automatically includes all subcategories — legacy storefront: hierarchy traversal is capped at 5 levels deep. REST API consumers using the
categoryDescendantIdfilter on/rest/productsget unlimited depth viaCategory\Service::getDescendantIds() - Filter availability is depth-dependent — tags, attributes, and variation filters only appear when the category is deep enough in the hierarchy (configurable thresholds)
- All product queries are cached with configurable TTL for performance; since 4.128 an empty listing (an empty category, or a filter combination matching nothing) is cached too, so crawler-driven filter URLs do not re-run the listing query (#666)
- Only active products with price > 0 are displayed; soft-deleted and zero-price items are hidden
- The sidebar offers a tag option only when clicking it would still show at least one in-stock product; tags already selected always stay listed so they can be removed (#941)
- A request with more than 4 distinct active tag filters (configurable,
APP_MAX_ACTIVE_TAG_FILTERS) is refused with HTTP 410 Gone before any product query runs (#940); this bounds the cost a scraper can impose through tag-filter URLs
API Reference
REST Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /rest/product/category | Guest | List categories with filtering, sorting, pagination |
| GET | /rest/product/category/{id} | Guest | Get category by ID |
| GET | /rest/product/category/item | Guest | Get single category by filter |
| POST | /rest/product/category | Backend (Products) | Create category |
| POST | /rest/product/category/{id} | Backend (Products) | Update category |
| DELETE | /rest/product/category/{id} | Backend (Products) | Delete category |
Available filters: id, parentId, order, published, isSensitive, name.{locale}, slug.{locale}
Available sorts: id, parentId, order, published, name.{locale}, slug.{locale}
Available relations: translations, parent, children, tagGroups, relativeCategories, articles
Browse endpoints interactively in the API Reference.
Legacy Storefront
| URL Pattern | Controller | Method |
|---|---|---|
/{category-slug} | Adv_eshop.php → Adv_product_categories.php | index($slug, $page) |
/{category-slug}/{page} | same | same (with pagination offset) |
Code Flow
Step 1: URL Resolution
File: ecommercen/eshop/controllers/Adv_eshop.php — _remap() (line 17) → baseCategory() (line 113)
The universal dispatcher tries category slug resolution after product slug fails (baseProduct(), line 57). parseCategorySlugAndOffset() splits the URL — if the last segment is numeric, it's a page number.
Category existence verified via PSCache: product_category_model->existsBySlug($slug) (line 117) — uses slug_lang composite index on shop_product_category_mui. Because every URL passes through baseProduct() first, its product-slug, category-slug and canonical-URL lookups (lines 67-96) opt into Pscache negative caching since #666, so a dead URL's misses are served from cache; the baseCategory() lookup at line 117 is not opted in and still runs on every miss (see SY-07 Cache Management).
Step 2: Category & Hierarchy Loading
File: ecommercen/eshop/controllers/Adv_product_categories.php — index() (line 63-458)
- Load category (line 68): Cached fetch by slug. Returns 404 if not found or unpublished.
- Calculate depth (line 90):
calcCategoryDepth()traverses parent chain viagetCategoryParentMap(). Depth controls which sidebar filters appear. - Read and cap the tag filters (line 101-148): only when
useTags()(depth >=category_level_for_tags_in_sidebar, line 992-995) the slugs come from thetag_filter_query_stringquery parameter and are deduplicated withUniqueCollection(line 101-108); on a shallower category the parameter is ignored. Then the cap guard (#940, line 110-113):tooManyActiveTagFilters()(line 1004-1007) is true when the value is an array of more thanmaxActiveTagFilters()slugs (line 997-1002:(int) env('APP_MAX_ACTIVE_TAG_FILTERS', 4), any value <= 0 becomes 4), andindex()callserror410()and returns — no listing, price-range or tag-existence query runs and no session key is written.error410()renders the 404 page layout with status 410 (ecommercen/core/Adv_base_controller.php:150-161). Only then is every selected slug checked againstgetTagsMuiAll(line 119-148): one unknown slug answers 404. - Expand to all children:
getCatProductsBase()executes a 5-level self-join onshop_product_categoryto collect ALL descendant category IDs (onlypublished = 1included).
Step 3: Filter & Sort Application
File: same controller (line 227-318)
Filters loaded from session (persisted across interactions) and URL query params:
| Filter | Config Gate | Query Mechanism |
|---|---|---|
| Price range | Registry ENABLE_PRODUCT_PRICE_RANGES | shop_prices_view.final_price >= / <= |
| Vendor | Always available | shop_product.vendor_id = |
| Tags | category_level_for_tags_in_sidebar vs depth; at most APP_MAX_ACTIVE_TAG_FILTERS | One correlated subquery per tag category over shop_product_product_tags, AND/OR per the category's flags (Step 4a); no pivot join |
| Attributes | category_level_for_attributes_in_sidebar vs depth | JOIN product_code_attributes by group ID |
| Variations | category_level_for_variations_in_sidebar + enableProductVariations | JOIN product_variation_values |
Sorting uses session values or defaults from registry (DEFAULT_FILTER_FRONT_ORDER, DEFAULT_FILTER_FRONT). Out-of-stock products pushed to end when LOW_STOCK_END_OF_LIST is enabled.
Step 3b: Per-Page Selector (sticky session, #298 / 4.109)
Files: ecommercen/helpers/theme_helper.php, ecommercen/eshop/controllers/Adv_product_categories.php, ecommercen/core/Adv_front_controller.php
The storefront exposes a "show N per page" control whose value persists in session key max_page_products across page navigations.
Initialization — Adv_front_controller::__construct() sets the default:
php
// ecommercen/core/Adv_front_controller.php:97
$this->limit = config('products_list_limit'); // default 36POST handling — when a customer changes the selector, maxPageLimitsPost() validates the posted max_limit against the pageLimitsArray() allow-list and stores it in session; tampered or legacy values (including the old 1000 / "ALL" option removed in #298) are silently dropped:
php
// ecommercen/helpers/theme_helper.php:18-38
function maxPageLimitsPost() { ... } // allow-list validation → session writeSession read-back — Adv_product_categories::index() restores the sticky value before querying:
php
// ecommercen/eshop/controllers/Adv_product_categories.php:259-261
if ($this->session->userdata('max_page_products')) {
$this->limit = $this->session->userdata('max_page_products');
}Defensive ceiling clamp (new in #298) — immediately after the session read, $this->limit is clamped down to productsListMaxLimit() (products_list_max ceiling, default 72). This neutralizes any session that was saved while the old 1000 option was still present:
php
// ecommercen/eshop/controllers/Adv_product_categories.php:263-266
$maxPageLimit = productsListMaxLimit();
if ((int) $this->limit > $maxPageLimit) {
$this->limit = $maxPageLimit;
}Allow-list build — pageLimitsArray() returns the permitted option set, filtered to values <= max with the ceiling always included; it no longer contains 1000:
php
// ecommercen/helpers/theme_helper.php:128-145
function pageLimitsArray() { ... } // returns {9, 18, 36, 72} when max=72Step 4: Product Query
File: ecommercen/eshop/models/Adv_product_model.php — getCatProductsProducts() (line 832-964)
Complex SQL joining: shop_product → shop_product_mui → shop_product_category_lp → shop_product_vats → shop_vendor → shop_vendor_mui, plus conditional joins for active attribute and variation filters. WHERE clause enforces: soft_delete = 0, lang = current, category IDs from hierarchy; the tag predicate is added at line 920-922, and once any tag, attribute or variation filter is active getWhereProductsActive() (line 924-926, body at line 4136-4142) also requires stock (product_codes.stock > 0 OR negative_stock = 1), active = 1 and price > 0. A query with no rows (or a failed query) returns false (line 942-944).
The controller fetches the page listing through PSCache with $cacheNegative = true (Adv_product_categories.php:293-318, #666), so a false (zero products) is cached for the TTL like a non-empty result, unless a database statement failed during the call; the second, unfiltered allProductsOfCategory call (line 320-334) is not opted in. Mechanics in SY-07 Cache Management.
Step 4a: Tag Filter Predicate (#939)
File: ecommercen/eshop/models/Adv_product_model.php — queryForListingTagFilters() (line 1004-1009) → listingTagFilterPredicate() (line 1018-1043) → listingTagFilterParts() (line 1052-1106)
tagFiltersPrepare() (line 4170) resolves the category-slug/tag-slug values into tag ids grouped by tag category, AND-behaviour categories first. For each tag category with selected tags T, the predicate uses two subqueries on the pivot (ptf_N aliases, line 1080-1081 and 1090-1091):
- any(T):
EXISTS (SELECT 1 FROM shop_product_product_tags ... tag_id IN (T)) - all(T):
(SELECT COUNT(DISTINCT tag_id) ... tag_id IN (T)) = |T|
tag_category_behavior | tag_values_behavior | Mandatory any(T) | Category term |
|---|---|---|---|
AND (0) | AND (0) | yes | all(T) |
AND (0) | OR (1) | yes | 1 (already implied) |
OR (1) | AND (0) | yes | 1 (already implied) |
OR (1) | OR (1) | no | any(T) |
The terms are chained in category order, each joined by its own category's connector (AND for an AND category, OR for an OR category), with SQL's AND-before-OR precedence; the mandatory any(T) checks are ANDed in front (line 1085-1087, 1037-1042). This reproduces exactly what the former per-tag pivot joins returned, including their mixed AND/OR behaviour, while removing their row fan-out (a product carrying j of a category's k selected tags produced about j^(k+1) rows before GROUP BY, which held a connection for 144 s on one tenant). COUNT(DISTINCT) and EXISTS are immune to duplicate pivot rows. Tag ids are cast to int before entering the SQL (line 1065).
When no selected tag resolves (for example, the only selected tag is carried by no product), the predicate is null and queryForListingTagFilters() emits 1 = 0 (line 1008): the listing is empty through valid SQL, where the old joins produced a failing query. A selection in which only some tags resolve drops the unresolved ones, as before.
The REST filter[tagFacetId] (src/Domains/Product/Product/TagFacetResolver.php, .../Repository/Specification/FilterByTagFacet.php) uses the same subquery vocabulary but reproduces what the WHERE structure means, not the join artefacts above; the two agree on the default configuration (every category AND, values OR) and on an all-OR configuration, and diverge on mixed ones (recorded in the FilterByTagFacet docblock). See AD-02 Product Management for that filter.
Step 5: View Assembly
Product data enriched with live pricing, product codes (SKUs), and images via defaultProductParseWithProductCodes() (inherited from Front_c). Sidebar built by catDynExtra() (line 550): category menu, vendor list, tag filters (buildTagsSideMenu(), line 557), variation filters, attribute filters, category slider, child categories. Block builder content rendered for category descriptions.
Step 5a: Sidebar Tag Options (#941)
Files: Adv_product_categories.php — buildTagsSideMenu() (line 864-934), filterOfferableTagRows() (line 944-985); Adv_product_model.php — getOfferableListingTagIds() (line 1130-1184)
The candidate rows still come from product_tag_lp_model::getUsedTags() over the products of the category (line 866-873), so names, ordering and the FILTER_CATEGORY_GROUP_TAGS_ENABLED group filter (line 877-888) are unchanged. filterOfferableTagRows() (line 875) then keeps a row only when its tag is either already selected (from jsonState['tagRecordsUsed'], line 955-960) or in the set getOfferableListingTagIds() returns. Both outputs are filtered by this one step: the PHP fallback rows (render['tagFilter']) and the Vue groups (jsonState['listingTagGroupCombos'], line 932). A selected tag keeps its group, which AdvListingUsedFilters.vue needs to build the chip's remove link.
A tag t is offered when the listing for "current selection + t" would be non-empty: the same category subtree, price/active conditions, vendor, attribute and variation filters as getCatProducts() (startListingFacetBase(), line 1363-1402), the predicate of Step 4a with t added to its category's IN list (listingTagFilterPredicate()'s optional $candidateCategoryId / $candidateColumn, line 1074-1077), and the stock check always applied, because a click always makes a tag filter active. Only tags carried by a product of the subtree are candidates (listingCandidateCarriedSql(), line 1350-1357), and an already-selected tag is never returned. The computation is 1 + k SELECTs, where k is the number of tag categories with a selection: one statement for all candidates of unselected categories (their modes are read from columns, listingUnselectedFacetSql(), line 1193-1259) and one per selected category (listingSelectedFacetSql(), line 1267-1306); the slug, attribute and variation lookups run once (line 1143-1152).
The whole set is one Pscache call in the product_model group, keyed on category id, conditions, attribute filters, vendor, tag slugs and variation filters (Adv_product_categories.php:962-973), not opted into negative caching. If a facet statement fails the method returns null (line 1170-1172); filterOfferableTagRows() then keeps every row (line 975-977), and Pscache never serves that null to a non-opted caller, so the next render retries. The facet reads its inputs from $this->internal['activeTagFilters'], ['productQueryConditions'] and ['filter_vendor'], set in index() (line 117, 290-291); without productQueryConditions the filtering is skipped and every row stays (line 948-950).
Domain & REST Architecture
Domain Layer
Category domain
| Component | Path | Purpose |
|---|---|---|
| Service | src/Domains/Product/Category/Service.php | Read service with specification-based queries |
| Repository | src/Domains/Product/Category/Repository/Repository.php | match(), matchOne(), get(), count() |
| Entity | src/Domains/Product/Category/Repository/Entity.php | Maps shop_product_category columns |
| MUI Repository | src/Domains/Product/Category/Repository/MuiRepository.php | Handles shop_product_category_mui translations |
| WriteService | src/Domains/Product/Category/WriteService.php | CRUD operations via REST |
| Configurator | src/Domains/Product/Category/Repository/RepositoryConfigurator.php | Declares relationships (parent, children, tags, articles) |
| FilterByTranslation | src/Domains/Product/Category/Repository/Specification/FilterByTranslation.php | Subquery spec: filters by translated column (name.{lang}, slug.{lang}) without joining _mui into the main query (#330). Since #762 other domains use the shared Support\Repository\Specification\FilterByTranslation (see SY-23 MUI Translation Pattern); category's own class is kept |
| SortByTranslation | src/Domains/Product/Category/Repository/Specification/SortByTranslation.php | LEFT JOIN spec: sorts by translated column (name.{lang}, slug.{lang}) with locale-scoped join on shop_product_category_mui (#333) |
Product domain (category-filtered listing)
| Component | Path | Purpose |
|---|---|---|
| Product Service | src/Domains/Product/Product/Service.php | Injects Category\Service; intercepts categoryDescendantId filter via buildCategoryDescendantFilter() |
| Product ListRequest | src/Domains/Product/Product/ListRequest.php | Exposes categoryId (direct) and categoryDescendantId (BFS recursive) filters |
| FilterByCategory | src/Domains/Product/Product/Repository/Specification/FilterByCategory.php | Subquery spec: shop_product.id IN (SELECT product_id FROM shop_product_category_lp WHERE category_id IN (...)) |
Additional listing filters, sort and flag on GET /rest/product/product:
| Param / field | Citation | Behavior |
|---|---|---|
filter[topSeller]=1 | src/Domains/Product/Product/ListRequest.php:75, Service.php:109-117 -> FilterByTopSeller | Truthy keeps the storefront's top-seller set (at most 500 products); falsy applies no filter |
sort=sales | ListRequest.php:220, Service.php:220-222 -> SortBySales | Ranks by order lines in the 3-month tmp_shop_order_basket window, not by hits page views; e.g. filter[topSeller]=1&sort=-sales,id |
filter[averageRatingGte]=N | ListRequest.php:70, Service.php:191-196 | Inclusive lower bound on shop_product.average_rating for "N stars and up" tiers (=4 returns 4.0, 4.5 and 5.0); filter[averageRating] stays an exact match (#787). A non-numeric bound is ignored for that key only (response still 200); unrated products (average_rating 0) are excluded by any positive bound |
filter[reviewCountGte]=N | ListRequest.php:71, Service.php:191-196 | Inclusive lower bound on shop_product.review_count; filter[reviewCount] stays exact (#787). Same non-numeric rule. See AD-02 Product Management for the full endpoint contract |
isTopSeller (boolean) | src/Rest/Product/Resources/Product/Resource.php:56,112 | Present on every row of GET /rest/product/product, /{id} and /item |
filter[priceDrop]=1|0 | ListRequest.php:79, Service.php:119-130 -> FilterByPriceDrop | 1/true keeps products with a fresh Omnibus price drop, 0/false the complement, other values apply no filter; needs the modern TrackPrices job and the product_price_drop table (migration database/migrations/20261003120000_create_product_price_drop.php). See SY-04 Price Tracking for the mechanics |
Storefront row scoping (#613). A REST consumer paging this category-descendant listing (
GET /rest/product/product?filter[categoryDescendantId]=...) is subject to the same storefront scope as the plain product collection: guest/customer callers receive onlyactive = 1 AND soft_delete = 0rows regardless ofcategoryDescendantId, andfilter[active]/filter[softDelete]are server-forced rather than honored. Zero-priced products are not additionally hidden. See CF-02 Product Detail for the full mechanism. This does not apply to the legacy category page (Step 4below), which is a separate code path with its own, narrower conditional filtering.
Legacy ↔ Domain Mapping
| Legacy Model Method | Domain Equivalent |
|---|---|
get_content($slug) | Service->item(ListRequest with slug filter) |
existsBySlug($slug) | Repository->count(Filter('slug', $slug)) |
get_arr_path($catId) | No domain equivalent (breadcrumbs stay in legacy) |
getCatProductsBase() (hierarchy expand) | Category\Service::getDescendantIds($rootId) — cycle-safe BFS, no depth cap |
getCatProductsProducts() (product query) | Product Service::all() with categoryDescendantId filter |
| Combined (hierarchy + product query) | Product Service::all(ListRequest with filter[categoryDescendantId]=$rootId) |
Client Extension Points
Controller Hooks
| Hook | Location | Purpose |
|---|---|---|
catDynExtra() | Adv_product_categories.php line 550 | Sidebar components (menus, vendor list, filters) |
buildTagsSideMenu() / filterOfferableTagRows() | line 864 / line 944 | Tag sidebar rows and their offerable-tag filter (#941) |
maxActiveTagFilters() / tooManyActiveTagFilters() | line 997 / line 1004 | The tag-filter cap and its check (#940); override maxActiveTagFilters() for a hard-coded cap |
Override in: application/modules/eshop/controllers/Adv_product_categories.php
A fork that re-implements index() without calling parent::index() must copy the cap guard (line 110-113) and set $this->internal['activeTagFilters'], ['productQueryConditions'] and ['filter_vendor'] before catDynExtra(), or it gets no cap and an unfiltered or wrong tag sidebar (override notes in docs/changelog/Changelog.4.128.md).
Model Overrides
| Model | Key Methods | Override In |
|---|---|---|
Adv_product_model | getCatProductsBase() (hierarchy), getCatProductsProducts() (query), queryForListingTagFilters() / listingTagFilterPredicate() (tag predicate), getOfferableListingTagIds() (sidebar facet) | application/modules/eshop/models/ |
Adv_product_category_model | get_arr_path() (breadcrumbs), getRecordsTree() (tree) | application/modules/eshop/models/ |
queryForListingTagFilters() keeps its signature; a fork that overrides it without calling the parent (Discount, Dioptra, Edructer, Elxis as of 2026-10, per docs/decisions/939-tag-filter-join-fanout.md) keeps its own join-based filter and does not get #939 through the upstream merge. queryForTag() (line 4149) is no longer called upstream and is kept unchanged for those overrides. The facet copies the non-tag clauses of the upstream getCatProductsProducts(), so where a fork overrides the listing, the sidebar can offer a tag whose click returns nothing, or hide one that would return products.
DI Container Overrides (Client Repos)
Override Domain layer via custom/Domains/container.php:
php
$services->alias(
Advisable\...\RepositoryConfigurator::class,
Custom\...\RepositoryConfigurator::class
);Configuration (Registry / Config)
| Key | Purpose |
|---|---|
ENABLE_PRODUCT_PRICE_RANGES | Enable price range filter sidebar |
enableProductVariations | Enable variation filter sidebar |
category_level_for_tags_in_sidebar | Min depth to show tag filters; below it the tag query parameter is ignored |
APP_MAX_ACTIVE_TAG_FILTERS | Env var (optional, int, default 4; unset, blank, non-numeric or <= 0 mean 4). Largest number of distinct active tag filters on a category page; more answers 410 Gone. Read by maxActiveTagFilters() (Adv_product_categories.php:997-1002), documented commented-out in .env.example:283-285. New in #940 / 4.128. |
FILTER_CATEGORY_GROUP_TAGS_ENABLED (registry ESHOP) | Limit sidebar tag groups to those assigned to the category, or to its nearest ancestor that has any (Adv_product_categories.php:877-888, Adv_product_tag_categories_model.php:274) |
category_level_for_attributes_in_sidebar | Min depth for attribute filters |
category_level_for_variations_in_sidebar | Min depth for variation filters |
DEFAULT_FILTER_FRONT_ORDER / DEFAULT_FILTER_FRONT | Default sort direction and field |
LOW_STOCK_END_OF_LIST | Push out-of-stock products to end |
ENABLE_SPECIAL_DISCOUNTS | Enable special discount calculation |
category_product_lists | Enable curated product lists on categories |
products_list_limit | Default storefront per-page count (36). Config file only — application/config/app.php:45. Not a Registry key. |
products_list_max | Hard ceiling for the per-page selector on category and vendor pages (72). Config file only — application/config/app.php:48. Not a Registry key. Enforced by productsListMaxLimit() (ecommercen/helpers/theme_helper.php:10-23) and the clamp in Adv_product_categories::index(). New in #298 / 4.109. |
Data Model
shop_product_category — Category hierarchy
| Column | Type | Description |
|---|---|---|
id | INT AUTO_INCREMENT | Primary key |
parent_id | INT DEFAULT 0 | Parent category ID (0 = root) |
published | TINYINT(1) DEFAULT 1 | Visibility flag (0 = hidden from storefront) |
order | INT DEFAULT 0 | Display sort order within siblings |
is_sensitive | TINYINT(1) DEFAULT 0 | Sensitive content flag (e.g., age-gated products) |
block_id | INT NULL | Associated Block Builder content block |
shop_product_category_mui — Category translations
| Column | Type | Description |
|---|---|---|
id | INT AUTO_INCREMENT | Primary key |
category_id | INT | FK to shop_product_category |
lang | VARCHAR(2) | Language code (e.g., el, en) |
name | VARCHAR(255) | Translated category name |
slug | VARCHAR(255) | URL slug (indexed with lang as slug_lang) |
description | TEXT NULL | Category page description (HTML) |
meta_title | VARCHAR(255) NULL | SEO title |
meta_description | TEXT NULL | SEO description |
image | VARCHAR(255) NULL | Category image filename |
shop_product_category_lp — Product-to-category link
| Column | Type | Description |
|---|---|---|
product_id | INT | FK to shop_product |
category_id | INT | FK to shop_product_category |
Other tables involved
| Table | Purpose |
|---|---|
shop_product / shop_product_mui | Product data and translations |
shop_prices_view | Calculated final prices (for price range filtering) |
shop_vendor / shop_vendor_mui | Vendor data |
shop_product_product_tags | Product-to-tag associations |
product_variation_values | Variation option values |
product_code_attributes | Attribute values per SKU |
Known Issues & Security Gaps
5-level hierarchy cap in legacy storefront —
Adv_product_model::getCatProductsBase()(ecommercen/eshop/models/Adv_product_model.php:737) uses a static 5-level self-join. Categories nested deeper than 5 levels are silently excluded from legacy storefront listings. The domain layer (Category\Service::getDescendantIds()) has no depth cap. REST consumers usingcategoryDescendantIdare unaffected. Tracked as a legacy gap inAdvisable-com/ecommercen#198.Dead sixth JOIN in
getCatProductsBase()—ecommercen/eshop/models/Adv_product_model.php:749addsLEFT JOIN shop_product_category AS t6 ON t6.parent_id = t5.id AND t6.published = 1butt6.idis never included in the SELECT clause and the result loop reads onlylvl1–lvl5. The join fires on every legacy category page request and consumes unnecessary database resources without contributing to the result. Legacy-path only; the domaingetDescendantIds()has no equivalent dead join.The sidebar facet fails open only for its own SELECTs; a failed lookup before them is cached as an answer —
getOfferableListingTagIds()returnsnullonly when a facet statement fails (ecommercen/eshop/models/Adv_product_model.php:1170-1172). The lookups it runs first turn a DB failure into an ordinary empty value:getCatProductsBase()returns[](:758-760), so the method returns[](:1138-1141);tagFiltersPrepare()(:4186-4188) and the attribute/variation resolvers (:1148-1151) return no rows, so the set is computed as if that filter were not active. The Pscache call is not opted into negative caching (ecommercen/eshop/controllers/Adv_product_categories.php:962-973), so its DB-error guard does not apply and an array result is cached for the TTL. After a transient failure of the category-subtree query, the sidebar shows only the selected tags (:975-984) until the entry expires or the cache is cleared.The price-range bounds ignore the tag predicate —
getCatProductsPriceRange()(ecommercen/eshop/models/Adv_product_model.php:2317) still filters tags with one pivot join and a slugIN (...)list (:2352-2363), i.e. "carries any selected tag", not the AND/OR predicate of Step 4a, and it applies no stock check. Under AND-behaviour tag selections the min/max shown can come from products the listing excludes. It is called directly, not through Pscache (ecommercen/eshop/controllers/Adv_product_categories.php:1174-1180), so it runs on every render. Left out of #939/#941 by decision.A scalar tag parameter can fatal on top-level categories —
?<tag_filter_query_string>=x(not an array) passes the cap (tooManyActiveTagFilters()counts only arrays) and the existence check (:120, array-only), thencount($activeTagFilters)atecommercen/eshop/controllers/Adv_product_categories.php:441raises aTypeErroron PHP 8 whenshowProductCategoriesTopis on, the category is top-level and no page is given. Pre-existing, noted out of scope indocs/decisions/940-tag-filter-cap.md.An empty listing, once cached, stays empty after products are added — since #666 the zero-product result of the page listing is cached for the TTL (
ecommercen/eshop/controllers/Adv_product_categories.php:293-318), and no upstream product save clears theproduct_modelgroup. See SY-07 Cache Management, which owns this issue.
Tests
| Test | Covers |
|---|---|
tests/Integration/Legacy/Eshop/AdvProductModelListingTagFilterTest.php | #939: the subquery predicate returns the same product ids as the former join builder (held verbatim in an anonymous subclass as the oracle) for all four AND/OR flag combinations across two and three categories; implied terms emit no second subquery; no pivot join; a selection resolving to no tag yields no products from valid SQL |
tests/Integration/Legacy/Eshop/AdvProductModelOfferableTagIdsTest.php | #941: the facet set equals a brute-force "click" oracle across flag combinations; variation filters narrow it; a selected tag is never returned; a tag carried only by an out-of-stock product is not offered; at most one facet query per selected category plus one, each lookup once |
tests/Legacy/Eshop/AdvProductCategoriesOfferableTagsTest.php | #941: offered and selected tags kept in both render['tagFilter'] and listingTagGroupCombos; a selected tag keeps its group; one Pscache call with all listing inputs; a failed facet computation keeps every tag |
tests/Legacy/Eshop/AdvProductCategoriesTagFilterCapTest.php | #940: seam visibility and types; cap resolution from the env var (defaults for unset/blank/invalid/<= 0); over the cap index() answers 410 without running the listing; duplicate slugs count once; at the cap the request reaches the listing path |
tests/Integration/Domains/Product/Product/ServiceTagFilterTest.php | REST tagId / tagFacetId filters (comments updated for #939) |
Pscache negative caching (#666) is covered under SY-07 Cache Management. Gap: no test drives a full category render through catDynExtra() with a real database, and getCatProductsPriceRange() has no tag-filter test.
Related Flows
- CF-02 Product Detail — clicking a product from the grid
- CF-03 URL Routing — how category slugs resolve
- CF-04 Search — search results share the product grid component
- CF-12 Promotions — promo pages share product grid component
- CF-18 Product Tags — tag filtering mechanics
- CF-19 Vendors — vendor product pages apply the same per-page selector and listing cap
- CF-25 Variations — variation filtering
- AD-05 Category Management — admin CRUD for categories
- AD-15 Attributes & Tags — attribute and tag administration
Wiki Guides: Product queries use PSR-6 caching — see Cache System for adapter configuration and TTL settings. Image assets are served through the storage abstraction layer — see Storage Guide.
Shared Patterns
- SY-07 Cache Management — PSCache invalidation and TTL strategy used by product queries, and the opt-in negative caching of empty listings and dead URLs (#666)
- SY-23 MUI Translation Pattern — how
_muitables power multi-language category names and slugs - SY-28 Storage Abstraction — category and product image storage