Docs

Каталог Shop

uticms.shop.catalog · verified 2026-07-14

Обзор

Scope
Shop product-domain data и read/indexing services; исключает basket/order lifecycle

Ключевые понятия

Catalog Tree
Adjacency-list иерархия каталога, материализованная в lft, rgt и depth для nested-set reads.
Offer
Покупаемая вариация продукта с участием в stock/pricing.
Facet Entry
Denormalized index row для фильтрации catalog products на витрине.
Facet Index Version
Versioned facet representation, производимая indexer.

Структура

  • Catalog Domain
    • Tables
      • shop_catalogs
      • shop_catalog_translations
      • shop_brands
      • shop_brand_translations
      • shop_units
      • shop_unit_translations
      • shop_products
      • shop_product_translations
      • shop_catalog_product
      • shop_offers
      • shop_offer_translations
      • shop_product_relations
  • Commercial Data
    • Tables
      • shop_price_types
      • shop_prices
      • shop_warehouses
      • shop_stock
  • Indexes
    • Search
      • shop_search_index
      • shop_search_trigrams
    • Facetsshop_facet_entries
  • Services
    • Catalog TreeModules/Shop/Services/Catalog/CatalogNestedSetService.php
    • Search
      • SearchService
      • SearchIndexer
    • FacetsModules/Shop/Services/Facet/

Факты

  • Shop migrations создают отдельные catalog, brand, unit, product, offer, translation, product-catalog pivot и product-relation tables. authoritative
  • Shop migrations создают price types, prices, warehouses и stock tables как distinct commerce data structures. authoritative
  • CatalogNestedSetService пересобирает lft, rgt и depth из catalog parent_id и sort в database transaction. authoritative
  • Catalog nested-set rebuilding имеет suspension и re-entrancy guards для bulk operations. authoritative
  • Facet migration добавляет is_filterable к Shop custom fields и создаёт shop_facet_entries. authoritative
  • FacetIndexer пересобирает active products чанками, удаляет entries для missing/inactive products и может rebuild full или catalog-specific scope. authoritative
  • FacetIndexer может отложить product reindexing, пока global enabled flag false, поддерживая bulk import workflows. authoritative
  • CatalogTreeFacetHelper::descendantIds читает anchor lft/rgt и выбирает descendant catalog ids с nested-set bounds вместо загрузки полного catalog tree в память. authoritative

Инструкции

Rebuild Catalog Indexes

  1. завершить catalog/product mutations
  2. rebuild nested-set boundaries при изменении parentage или sort
  3. запустить appropriate Shop search/facet index rebuild
  4. проверить, что inactive products больше не имеют queryable facet rows

Правила

Architectural rule

Не мутируйте parent_id или sort bulk-операциями и не предполагайте валидные nested-set boundaries; rebuild или контролируйте automatic rebuild behavior.

Architectural rule

Rebuild/remove facet entries, когда product становится inactive или меняются filterable catalog data.

Примеры

Index Rebuild Commands

php artisan shop:facet-index --fresh
php artisan shop:search-index

modules/Shop/Console/Commands/RebuildFacetIndexCommand.php

Catalog Facet Filter

$ids = app(CatalogTreeFacetHelper::class)->descendantIds($catalogId, includeSelf: true);

modules/Shop/Services/Catalog/CatalogTreeFacetHelper.php