Understanding Magento EE URL Rewrites in Version 1.13
The recent update of Magento Enterprise Edition (EE) version 1.13 introduced significant changes to the way URL rewrites are handled, leaving many developers curious about the new architecture and database schema. This blog post aims to demystify these changes by explaining the purpose of the new tables and how they relate to each other.
New Database Tables for URL Rewrites
In version 1.13, Magento EE has introduced several new tables to manage URL rewrites more efficiently:
enterprise_url_rewrite: Stores all rewrite rules.enterprise_url_rewrite_category_cl: Associates categories with their respective rewrite records.enterprise_url_rewrite_product_cl: Links products to their rewrite entries.enterprise_url_rewrite_redirect_cl: Handles redirects for rewrites.enterprise_url_rewrite_redirect_rewrite: Maps redirect rules to rewrite rules.
Purpose of the New Tables
Let’s delve into each table and understand its role in the URL rewrite system:
1. enterprise_url_rewrite
This is the primary table that stores all rewrite rules for URLs, including product URLs, category URLs, CMS page URLs, and more. Each entry has a unique identifier (entity_id), the original URL (original_path), and the target URL (target_path).
2. enterprise_url_rewrite_category_cl and enterprise_url_rewrite_product_cl
These tables create an association between categories/products and their respective rewrite rules stored in enterprise_url_rewrite. The entity_id field in these tables references the primary key of the associated category or product entity.
For example, if you have a category with ID 123 and its URL is rewritten to /new-category, an entry will be created in the enterprise_url_rewrite_category_cl table linking the category_id (123) to the corresponding rewrite record (entity_id).
3. enterprise_url_rewrite_redirect_cl
This table manages redirects for URLs that have been rewritten or moved. It stores information about the original URL, the redirect target, and the HTTP status code.
4. enterprise_url_rewrite_redirect_rewrite
This table is a junction between enterprise_url_rewrite and enterprise_url_rewrite_redirect_cl. It maps rewrite rules to their corresponding redirects when necessary. This table ensures that if a URL’s target changes, the system can redirect both old and new URLs appropriately.
Changes in Model Access
Another notable change in version 1.13 is the modification of how models are accessed. Magento EE now uses a factory pattern (Mage_Core_Model_Factory) to load models dynamically based on XML configuration.
In the provided code snippet, you’ll notice that core/url_rewrite has been replaced with core/factory->getUrlRewriteInstance(). This change enables the system to handle multiple rewrite types more effectively and allows for easier customization of the rewrite model in the future.
Conclusion
Magento EE’s new URL rewrite architecture in version 1.13 aims to improve performance, scalability, and flexibility. The introduction of dedicated tables for categories, products, redirects, and rewrites enables better management of complex URL structures.
Understanding these changes is crucial for maintaining and customizing Magento EE installations effectively. Familiarizing yourself with the new database schema and model access patterns will help you make informed decisions when working on URL-related features or troubleshooting issues.
For more in-depth information about Magento development best practices, check out our expert guides at Laravel Company. Our team of experienced developers is always ready to provide tailored solutions and assistance for your Magento projects.