Is Using Flat Catalog Product Magento 2 Valid in 2025?
Need data retrieval for faster Magento catalog performance?
Use Flat Catalog Product Magento 2 boosts frontend speed by denormalizing tables. After Magento 2.4 deprecated it, Elasticsearch took its place, offering better performance.
This article explores the pros and cons of legacy Flat Catalog Product functionality.
Key Takeaways
-
Flat tables combined attributes to speed up frontend catalog operations.
-
Elasticsearch replaced flat tables in Magento 2.4, providing scalability.
-
Older extensions depended on flat table queries, creating dependencies.
-
Attribute limitations affected flat tables and inputs like multi-selects or tier pricing.
-
Magento's API supports Flat Catalog, EAV, and Elasticsearch.
What is Use Flat Catalog Product Magento 2?
“Use Flat Catalog Product was a Magento 2 setting (pre-2.4). The setting controlled how Magento stored and retrieved product data. Magento, by default, uses the EAV (Entity-Attribute-Value) model.”
EAV stores product attributes across several database tables, offering flexibility. Retrieving product data with EAV requires complex SQL joins.
Turning on "Use Flat Catalog Product" creates denormalized "flat" tables. These tables combine product attributes into one table. Querying a single table speeds up read performance for the frontend. It benefits catalog browsing, searching, and filtering operations for customers. A flat catalog requires reindexing to reflect EAV changes. A cron job updates flat tables.
Magento 2.4+ deprecated this setting, replacing it with mandatory Elasticsearch. Elasticsearch provides indexing and near real-time updates with speed. The legacy Flat Catalog is now obsolete in newer Magento versions.
Magento's EAV vs. Flat Catalog: Legacy Architecture Compared
1. Data Model and Structure
Feature/Aspect | EAV (Entity-Attribute-Value) | Flat Catalog |
---|---|---|
Data Structure | The system stores normalized data, spreading products and categories across many tables. It assigns a table to each attribute type. | The system denormalizes data, placing product and category data into one table. It assigns a column to each configured attribute. |
Database Schema | The schema features several tables with intricate relationships, making it complex. Adding attributes involves table changes. | The schema uses fewer tables, speeding up data retrieval. Adding attributes requires altering the flat table and reindexing. |
Space Complexity | The normalized structure avoids redundancy, saving space. | Denormalization takes more space due to data duplication. Flat tables can grow large with many attributes. |
Data Integrity | Normalization and database schema constraints maintain data integrity. | Denormalization weakens data integrity; updates can cause inconsistencies. |
2. Performance and Scalability
Feature/Aspect | EAV (Entity-Attribute-Value) | Flat Catalog |
---|---|---|
Performance (Read) | Joins slow down reading on listing pages. | The design speeds up frontend catalog performance, making reading faster. |
Performance (Write) | Individual saves are faster because the system updates attribute tables. | "Update on Save" makes single saves slower (not recommended). Batch processing via scheduled reindexing (cron) speeds things up. |
Scalability | The EAV model makes adding attributes easy. Query performance drops as the catalog grows. | The flat catalog boosts read scalability, but reindexing becomes a bottleneck. Elasticsearch provides better scalability in modern Magento. |
SQL Queries | The system needs several JOIN operations, slowing down with larger catalogs. Developers need complex queries to retrieve attributes. |
A single SELECT statement on the flat table works. The system reads data faster, speeding up listings and search results. |
3. Indexing and Updates
Feature/Aspect | EAV (Entity-Attribute-Value) | Flat Catalog |
---|---|---|
Indexing | Magento uses indexers, but EAV complexity remains. | The catalog_product_flat and catalog_category_flat indexers rebuild flat tables. They use EAV data and attribute configurations. |
Reindexing (Pre-2.4) | Reindexing EAV indexers is a faster process. | Reindexing the flat catalog takes time with large catalogs. Cron-scheduled updates are not real-time. |
Reindexing (2.4+) | EAV reindexing remains relevant, but Elasticsearch makes it less critical for catalog operations. | The deprecation of the flat catalog makes reindexing irrelevant. Elasticsearch handles indexing and searching. |
Cron Dependency (F) | N/A | The flat catalog depends on cron for updates (pre-2.4). The system shows outdated frontend data if the cron job fails. |
4. Development and Compatibility
Feature/Aspect | EAV (Entity-Attribute-Value) | Flat Catalog |
---|---|---|
Code Complexity (Retrieval) | EAV's intricacies make code complex, requiring developers to use Magento's API. Magento discourages direct SQL queries. | Querying is simpler, but developers should use Magento's API. Magento considers flat tables internal and subject to version changes. |
Code (Modification) | Using Magento's API keeps code simple. It applies changes to the right EAV tables. | Developers should not attempt direct modification; it is dangerous. Direct changes can cause inconsistencies and break Magento's functionality. |
Extension Compatibility | Extensions show more compatibility because they use Magento's API. | Older extensions querying flat tables may face issues. The problem was more common before Magento 2.4. |
Flexibility (Attributes) | The system supports attributes and input types well. | The system does not support some attribute types. Adding attributes requires reindexing and altering the flat catalog structure. |
Attribute Limitations(F) | N/A | The structure may not support "Multiple select". Custom types also pose a compatibility risk with the flat catalog. |
5. Usage and Deprecation
Feature/Aspect | EAV (Entity-Attribute-Value) | Flat Catalog |
---|---|---|
Use Cases (Pre-2.4) | Magento uses EAV for admin operations, data import/export, and backend logic. | Magento used the Flat Catalog for frontend catalog browsing, including searching and filtering. |
Use Cases (2.4+) | EAV remains the core data model but is less relevant to the front end. | Magento deprecated the Flat Catalog; it is not used for the frontend. Elasticsearch handles everything. |
Deprecation | EAV remains Magento's core data model for storing information. | Magento deprecated the flat catalog, starting with Magento 2.4 and later versions. |
Magento 2 Extension Compatibility and the Flat Catalog
1. Understanding Extension Dependencies
-
Magento extensions add custom functionality to the platform. Extensions interact with core Magento data structures.
-
Some older extensions query the flat catalog tables. Reading from flat tables is faster than querying EAV.
-
These extensions may have hard-coded SQL queries within the code. These queries reference
catalog_product_flat_*
tables. -
Hard-coded queries assume the flat catalog is on. The extension expects the flat tables to be present.
-
Extensions interacting with a flat table is a bad practice. Use Magento's API for interactions.
2. Risks of Disabling the Flat Catalog
-
Disabling the flat catalog breaks dependent extensions. Hard-coded SQL queries fail because the tables do not exist.
-
Extension breakage shows as errors, exceptions, and unexpected behavior. Issues can appear in your Magento store.
-
PHP errors will appear in Magento system logs. These errors point to problems with extension code execution.
-
Pages or sections depending on the extension may render blank. The blank output occurs where the extension's content should display.
-
The extension may show incorrect data on the frontend. Wrong prices, descriptions, or other product details may appear.
3. Identifying Flat Catalog Dependent Extensions
-
Check dependency by reading extension documentation. Reputable developers state dependencies and compatibility requirements.
-
A developer can examine the extension's code for direct queries. These queries reference
catalog_product_flat_*
orcatalog_category_flat_*
tables. -
code review means searching the code for function calls. Look for
getTable('catalog_product_flat')
or direct SELECT statements. -
Test changes in a staging or development environment first. Do not apply changes to a live production website.
-
Disabling the flat catalog on staging and testing is key. Check the usage of extension functionalities.
4. Mitigation Strategies for Flat Catalog Dependency
-
Keep the extension turned on (pre-2.4) if it is critical. The approach accepts the performance trade-offs of a flat catalog.
-
Check for updated extension versions from the provider. Updates should work with a disabled flat catalog.
-
Replace outdated extensions with modern alternatives. New extensions should not depend on the deprecated flat catalog.
-
A developer can alter the extension's code. The change removes the dependency on the flat catalog tables.
-
Disable non-essential extensions as a last resort. The action eliminates the conflict but removes functionality.
5. Magento 2.4+ and Extension Compatibility
-
Extension compatibility issues persist in 2.4+. Older extensions still have problems.
-
The focus shifts to Elasticsearch compatibility for extensions. Extensions should use Elasticsearch data, not the legacy flat catalog.
-
Older extensions may reference flat catalog tables. The same mitigation strategies (update, replace, change, disable) apply.
-
Magento's EAV model prefers rewriting queries. Using classes like
\Magento\Framework\EntityManager\EntityManager
is the best practice. -
Adapting the code to use Elasticsearch data is necessary. Developers should refactor extensions to work with the new system.
How to Handle Magento Flat Catalog Updates and Cron Jobs?
1. Flat Catalog Update Mechanism
-
The traditional Magento flat catalog (pre-2.4) is not update-automated. Data changes need a reindexing process to show on the frontend.
-
Update the EAV (Entity-Attribute-Value) tables for changes to product data. Denormalized flat catalog tables do not show these changes right away.
-
Without reindexing, the frontend shows customers outdated product information. Customers might see old prices, descriptions, or missing products.
-
Trigger a reindexing process. Reindexing reads data from EAV tables and rebuilds the flat tables.
-
Magento offers options for reindexing, including Manual and Scheduled approaches. Both serve specific scenarios.
2. Reindexing Options for the Flat Catalog
-
Trigger a reindex from the Magento admin panel yourself. The manual approach works for occasional changes or testing.
-
Manual reindexing is not practical for live stores with updates. Frequent manual work would take too much time.
-
Scheduled reindexing via cron job is the standard approach. Cron jobs run tasks at set intervals, like reindexing.
-
Magento uses cron jobs for background tasks system-wide. It includes reindexing the flat catalog tables.
-
Cron schedules reindexing as an update. The update depends on cron schedules rather than real-time changes.
3. Cron Job Configuration for Reindexing
-
A cron job is a command or script scheduled to run. The schedule can set execution every minute, hour, or day.
-
Unix-like systems hosting Magento use
crontab
. The tool manages scheduled cron jobs on the server. -
Each user on the system can define their own tasks. Users configure their
crontab
files. -
Magento has a built-in cron system for internal processes. The system works with the server's cron.
-
Magento defines cron tasks in
crontab.xml
files within modules. These files list the job code, instance, method, and schedule.
catalog_product_flat
Indexer
4. Understanding the -
The flat catalog reindexing process is a cron job. Magento's core Catalog module defines this job.
-
vendor/magento/module-catalog/etc/crontab.xml
contains the configuration. The file structure may differ between Magento versions. -
The
<job name="indexer_reindex_all_invalid" ...>
line defines the cron job. The job handlingcatalog_product_flat
ties to indexers. -
The
schedule>* * * * *</schedule>
line is the cron expression. The example means the job runs every minute. -
The indexer finds modified products since the last reindex. It reads updated data from EAV tables and updates flat tables.
5. "Automatic" Updates and Magento 2.4+
-
The "every minute" update is a sample schedule. The store should set the reindexing frequency based on its needs.
-
Frequent product updates need a more frequent reindex schedule. Consider running the reindexing process every 5 to 15 minutes.
-
Reindexing uses server resources, even when scheduled. Running it too often could strain your server.
-
Consider the acceptable delay for frontend updates. More frequent schedules bring updates closer to real-time.
-
Magento 2.4+ uses Elasticsearch, making the flat catalog obsolete. Elasticsearch provides near real-time, incremental indexing, a big step up.
Magento 2 Flat Catalog Attribute Limitations and Management
1. Flat Catalog Attribute Support
-
The flat catalog uses a single, wide table for product data. Each included attribute gets its column within this table.
-
Simple attributes, like text fields, dropdowns, and numbers, work fine. The system shows these attributes as single values within columns.
-
Complex attribute types challenge the flat catalog's design. These attributes do not fit into a single-column setup.
-
Including many attributes creates a wide, hard-to-handle flat table. The large table hurts database performance and query speed.
-
The flat catalog indexer might not process all custom input types. Custom attributes with special logic need careful setup for catalog compatibility.
2. Complex Attribute Types and the Flat Catalog
-
Multi-select attributes let users pick several options from a list. Showing several selections within one column is hard.
-
Product images and related data exist in separate database tables. The flat catalog stores the main image's path, excluding full gallery data.
-
Tier pricing includes quantity and price combination data. The flat catalog stores the base product price.
-
Grouped, configurable, and bundle products have complex relational structures. The flat catalog focuses on simple products, limiting data representation.
-
The structure can show Date and Time attributes. Filtering and sorting with these attributes can pose challenges.
3. Controlling Attribute Inclusion in the Flat Catalog
-
Magento controls attribute inclusion in the "Storefront Properties" section. Users access these settings from the Magento admin interface.
-
Setting "Used in Product Listing" to "Yes" includes the attribute. The setting makes the attribute's value available for listings.
-
Setting "Used in Product Listing" to "No" excludes the attribute. Retrieving the attribute then needs querying the slower EAV tables.
-
Setting "Used for Sorting" to "Yes" includes and speeds up the attribute. The action creates an extra index on the flat table.
-
Setting "Used for Sorting" to "No" impacts performance. Sorting by that attribute triggers a full table scan.
4. Best Practices for Flat Catalog Attribute Management
-
Magento administrators should include only essential attributes for product listings. Fewer attributes create a smaller, faster, flat catalog table.
-
Administrators should include attributes like name, price, and SKU. Customers use these core attributes for product comparisons online.
-
Store owners should avoid complex attribute types when filtering. Using these types without expertise can hurt performance.
-
Administrators must test attribute property changes. Testing confirms correct functionality on the Magento frontend.
-
Magento users can use attribute sets for attribute management. Attribute sets keep the flat catalog focused.
5. Magento 2.4+ and Elasticsearch Considerations
-
Magento 2.4+ deprecates the flat catalog functionality. Elasticsearch now handles indexing and searching duties.
-
Attribute properties still matter but affect Elasticsearch now. Properties like "Visible on Catalog Pages" remain relevant.
-
Store owners should configure Elasticsearch in newer versions. Traditional flat catalog management is less critical.
-
Older extensions or custom code might reference flat tables. The code needs updates or careful developer review.
-
The concept of attribute properties persists, even with Elasticsearch. These properties shape how the system handles and uses data.
FAQ
1. Can I turn on the flat catalog for specific store views?
Yes, Magento allows configuring the flat catalog at the store view level. The setup gives you control over its behavior across different websites. Navigate to Stores > Configuration > Catalog > Catalog > Storefront
. Then, pick the store view you want to change.
2. What happens to custom attributes if I disable the flat catalog after using it?
Disabling the flat catalog does not delete custom attributes. The attributes and their data stay in the EAV tables. The frontend stops using the flat tables for product retrieval. Magento will query the EAV tables, which may affect performance.
3. Are there database size implications when using the flat catalog?
Yes, the flat catalog increases database size. The growth happens because the flat tables store a denormalized copy. The copy includes data from several EAV tables in one table. Larger catalogs with many attributes will see a bigger size increase.
4. Does turning on the flat catalog affect my ability to use Magento's API?
No, turning on or off the flat catalog does not restrict API usage. Magento's API (Repositories, Service Contracts, Collection Factories) abstracts the data model. Developers should use the API for data interaction, regardless of setting. Direct querying of the flat catalog tables (or EAV tables) is not recommended.
5. Does using the flat catalog affect product import/export functionality?
The flat catalog setting does not impact import/export operations. Magento's import and export processes work with the EAV data structure. The presence of the flat catalog can affect perceived speed. Import processes triggering reindexing might take longer with it turned on.
6. Are there server configurations recommended when using the flat catalog?
Yes, ample server resources are mandatory when using the flat catalog. Pay attention to PHP's memory_limit
setting. The reindexing process can use significant memory for large catalogs. Adequate RAM and database server setups are also key.
Summary
Use flat catalog product Magento 2 speeds up frontend operations through denormalized tables. Its deprecation in 2.4+ shifted focus to Elasticsearch. The main points of the article include:
-
Denormalized tables sped up frontend catalog operations. Frequent cron reindexing keeps EAV data in sync.
-
Elasticsearch replaced flat tables in Magento 2.4+. Real-time indexing updates with better scalability.
-
Complex attributes risked flat catalog compatibility. Multiselect or tier pricing needed careful inclusion.
-
Legacy extensions depending on flat tables risked errors. Post-2.4 code reviews ensured Elasticsearch compatibility.
-
Core attributes (SKU, price) reduced table bloat. Selective inclusion balanced performance with data flexibility.
Opt for Managed Magento Hosting for both legacy flat catalog and Elasticsearch support.