After I have seen that some 3rd party modules duplicate the core_url_rewrite
table to store there additional category rewrite information in it (1), I came to the conclusion that it should be save to remove the joinLeft()
in the flat table classes.
Instead of the joinLeft()
you simply refer to the column main_table.url_path as request_path
in the tables catalog_category_flat_store_[StoreId]
. Please see the new methods.
Downside: To get the correct rewrites in the frontend you need to run the reindex for catalog_category_flat
. During this reindex the correct rewrites will be inserted into the column catalog_category_flat_store_X.url_path
.
Footnotes:
(1) the join with the core_url_rewrite
takes for large product collection really long when you only need the correct rewrite for the categories. This can save per request around ~0.Xsec.
Btw: in Mage_Catalog_Block_Seo_Sitemap_Product::_prepareLayout()
the collection is loaded without any join on core_url_rewrite
so each product listed will create a select like:
SELECT `core_url_rewrite`.* FROM `core_url_rewrite` WHERE (`core_url_rewrite`.`id_path`='product/158') AND (store_id IN(0, '2')) ORDER BY `store_id` DESC LIMIT 1
After your comment on mklooss/Loewenstark_UrlIndexer#1 i thought about a new method to save the category urls, like product url (own hidden Attribute), so we did not need a join/leftjoin for this cases (if flat table is active for categories).
also finding the current product url (Mage_Catalog_Model_Url::getProductRequestPath).
when 2 Products have the same url_key magento create a every reindex process a new url for on of this products
and the Sitemap Module have to be refactore. - MemoryLeak etc. on 1.5 Mio Article the sitemap need like more than an hour and use more then 6 GB RAM
https://github.com/Zookal/magento-ce/blob/magento-1.7.0.2/app/code/core/Mage/Sitemap/Model/Sitemap.php#L171
https://github.com/Zookal/magento-ce/blob/magento-1.7.0.2/app/code/core/Mage/Sitemap/Model/Resource/Catalog/Product.php#L170