Skip to content

Architecture Overview

Deep dive into Magento's largest module: EAV implementation, 148 service contracts, 63 database tables, 6 indexers, and the foundation of all product/category functionality.

148 Interfaces 63 Tables 6 Indexers

Module Position in Ecosystem

Magento_Catalog is the largest and most complex module in Magento 2. It serves as the foundation for all product and category management, implementing the Entity-Attribute-Value (EAV) pattern for flexible attribute storage.

Critical Insight: Understanding the EAV architecture is essential before working with any catalog-related functionality. Misunderstanding it leads to N+1 queries, performance issues, and incorrect data retrieval.

Module Stats

  • Total PHP Files:2120
  • Service Contracts:148
  • Database Tables:63
  • Models:1118
  • Blocks:338
  • Controllers:182
  • Indexers:6

EAV Architecture

Entity-Attribute-Value (EAV) is Magento's flexible data storage pattern that allows unlimited custom attributes without schema changes. Products and Categories are EAV entities.

Entity

The main record (product/category) stored in catalog_product_entity

Attribute

Definition of a field (name, type, scope) in eav_attribute

Value

Actual data split by type: _varchar, _int, _decimal, _datetime, _text

EAV Tables for Products

catalog_product_entity          -- Main entity table (entity_id, sku, type_id, attribute_set_id)
catalog_product_entity_varchar  -- String values (name, url_key, meta_title)
catalog_product_entity_int      -- Integer values (status, visibility, tax_class_id)
catalog_product_entity_decimal  -- Decimal values (price, weight, special_price)
catalog_product_entity_datetime -- Date values (special_from_date, news_from_date)
catalog_product_entity_text     -- Long text (description, short_description)

Performance Warning

EAV requires multiple JOINs to retrieve a complete entity. This is why Magento has Flat Tables and Indexers to denormalize data for read-heavy operations. Always use the Flat catalog for frontend queries when possible.

Service Contracts (148 Interfaces)

Magento_Catalog exposes 148 service contract interfaces: 36 top-level repository/management interfaces and 35 Data interfaces (DTOs). These form the stable API layer.

Core Repository Interfaces

  • ProductRepositoryInterface CRUD operations for products
  • CategoryRepositoryInterface CRUD operations for categories
  • ProductAttributeRepositoryInterface Manage product attributes
  • CategoryAttributeRepositoryInterface Manage category attributes
  • AttributeSetRepositoryInterface Manage attribute sets

Key Data Interfaces (DTOs)

  • ProductInterface Product data transfer object
  • CategoryInterface Category data transfer object
  • ProductAttributeInterface Attribute metadata DTO
  • ProductLinkInterface Related/cross-sell/upsell links
  • ProductCustomOptionInterface Custom options DTO

Database Schema (63 Tables)

Magento_Catalog defines 63 database tables covering EAV storage, flat tables, indexer data, gallery, links, and more.

Product EAV (6 tables)

  • catalog_product_entity
  • catalog_product_entity_varchar
  • catalog_product_entity_int
  • catalog_product_entity_decimal
  • catalog_product_entity_datetime
  • catalog_product_entity_text

Category EAV (6 tables)

  • catalog_category_entity
  • catalog_category_entity_varchar
  • catalog_category_entity_int
  • catalog_category_entity_decimal
  • catalog_category_entity_datetime
  • catalog_category_entity_text

Relationships (8 tables)

  • catalog_category_product
  • catalog_category_product_index
  • catalog_product_link
  • catalog_product_link_type
  • catalog_product_relation
  • catalog_product_super_link
  • catalog_product_website
  • catalog_product_super_attribute

Price Index (5 tables)

  • catalog_product_index_price
  • catalog_product_index_price_final_idx
  • catalog_product_index_price_opt_idx
  • catalog_product_index_tier_price
  • catalog_product_index_website

Gallery (4 tables)

  • catalog_product_entity_gallery
  • catalog_product_entity_media_gallery
  • catalog_product_entity_media_gallery_value
  • catalog_product_entity_media_gallery_value_to_entity

Flat Tables (4 tables)

  • catalog_product_flat_* (per store)
  • catalog_category_flat_* (per store)
  • catalog_product_index_eav
  • catalog_product_index_eav_decimal

Key Schema Relationships

catalog_product_entity.entity_id  →  catalog_product_entity_*.entity_id (EAV values)
catalog_product_entity.entity_id  →  catalog_category_product.product_id (category assignment)
catalog_category_entity.entity_id →  catalog_category_product.category_id (category assignment)
catalog_product_entity.entity_id  →  catalog_product_link.product_id (related/upsell/crosssell)

Product Types

Magento_Catalog defines the base product types. Additional types are added by other modules (Bundle, Configurable, Grouped, Downloadable).

Simple Product

  • Type ID: simple
  • Model: Magento\Catalog\Model\Product\Type\Simple
  • Index Priority: 10
  • Composable: Yes (can be part of configurable/bundle)
  • Refundable: Yes

Virtual Product

  • Type ID: virtual
  • Model: Magento\Catalog\Model\Product\Type\Virtual
  • Index Priority: 20
  • Composable: Yes
  • Refundable: No (is_real_product = false)

Extended Product Types (Other Modules)

  • configurable - Magento_ConfigurableProduct
  • bundle - Magento_Bundle
  • grouped - Magento_GroupedProduct
  • downloadable - Magento_Downloadable

Category Tree Structure

Categories use a nested set model with path-based hierarchy. Each store has a root category, and all navigation categories are descendants.

Key Fields

  • entity_id: Unique category identifier
  • parent_id: Direct parent category
  • path: Full ancestry (e.g., "1/2/15/42")
  • level: Depth in tree (root = 0)
  • children_count: Number of direct children
Root Category (ID: 1, path: "1", level: 0)
└── Default Category (ID: 2, path: "1/2", level: 1)
    ├── Men (ID: 11, path: "1/2/11", level: 2)
    │   ├── Tops (ID: 12, path: "1/2/11/12")
    │   └── Bottoms (ID: 13, path: "1/2/11/13")
    └── Women (ID: 14, path: "1/2/14", level: 2)
        └── Dresses (ID: 15, path: "1/2/14/15")

Indexers (6 Core)

Magento_Catalog provides 6 core indexers that denormalize EAV data for performance and maintain relationship indexes.

catalog_product_flat

Reorganize EAV product structure to flat structure for fast frontend queries.

Performance Critical

catalog_category_flat

Reorganize EAV category structure to flat structure.

Performance Critical

catalog_category_product

Indexed category/products association for navigation.

Shared Index

catalog_product_category

Indexed product/categories association (reverse lookup).

Shared Index

catalog_product_price

Index product prices including tier prices and special prices.

Price Calculation

catalog_product_attribute

Index product EAV attributes for layered navigation.

Layered Nav

Module Dependencies

Magento_Catalog has strict sequence dependencies that determine load order.

Required Dependencies (module.xml sequence)

  • Magento_Eav

    EAV framework for attribute storage

  • Magento_Cms

    CMS block widgets in categories

  • Magento_Indexer

    Indexer framework for flat tables

  • Magento_Customer

    Customer group pricing

Modules That Depend on Catalog

  • Magento_ConfigurableProduct
  • Magento_Bundle
  • Magento_GroupedProduct
  • Magento_Downloadable
  • Magento_CatalogInventory
  • Magento_CatalogSearch
  • Magento_CatalogRule
  • Magento_CatalogUrlRewrite
  • Magento_Quote
  • Magento_Sales
  • Magento_Checkout
  • ... and 50+ more modules