Magento URL Indexing and core_url_rewrite table

Can someone shed some light on how Magento determines whether to create a new rewrite URL for the product? Each time I start the process of renaming directory URLs, the number of lines in core_url_rewrite increases by about 10,000 lines. Since product data has not been changed on average, why is a new URL being created?

+6
source share
4 answers

This problem still exists in Magento 1.7, but I have no idea about 1.8 or 1.9. Magento doesn't seem to be deleting old records. This can seriously slow down your database. The easiest way to solve this problem is to crop the table and reindex it.

  • Log in to mysql and select (use) the appropriate database
  • Run the following query: truncate table core_url_rewrite;
  • Go to the shell folder in the magento root folder (commandline) and run the following command: php -f indexer.php -- -reindex catalog_url
  • Alternatively, you can do this in admin: System> Index Management; Reindex Rewrites Directory URL

Then go to admin: Catalog> Rewrite Management and check if new entries have been created. If there are no elements in this case, URL rewriting will not work!

+1
source

You can run the following SQL to find out which URLs belong to non-existing products:

 SELECT `cur`.`product_id` FROM `core_url_rewrite` AS `cur` LEFT OUTER JOIN `catalog_product_entity` AS `cpe` ON `cur`.`product_id` = `cpe`.`entity_id` WHERE `cpe`.`entity_id` IS NULL AND `cur`.`product_id` IS NOT NULL 

... you should see a list of entity objects that are not in

 `catalog_product_entity` 

EcomDev has a free URL rewriting module ( http://shop.ecomdev.org/url-rewrite-indexer.html ), which I found useful.

EDIT

To answer the question, new URLs are generated, because when reindexing the URLs is done, follow these steps:

 Mage_Catalog_Model_Indexer_Url::reindexAll() 

... which is a wrapper around:

 Mage_Catalog_Model_Url::refreshRewrites 

... verification is not performed if the data has been changed. If you need something, you can override this class and rewrite functionality to compare differences.

0
source

I am using Magento 1.8, and my core_url_rewrite table has about 5 million !!!! records. Finally, I rewrote the beforeSave function in Mage_Catalog_Model_Product_Attribute_Backend_Urlkey and generated my own URL key from the first five words of the product name. If the first 5 words are not unique, I add a few numbers. If anyone is interested in my code, I can post some snippets.

after overwriting Mage_Catalog_Model_Product_Attribute_Backend_Urlkey I truncated core_url_rewrite and restored the index. finally i got about 60,000 urls ... and the reindex process is not adding new ones.

but you should keep in mind that custom URL rewrites are lost when truncating and rearranging the core_url_rewrite table. And maybe you are having some unexpected problems with your seo head. cause all 302er redirects

amuses

0
source

This issue arose because of a known bug in the product and category indexing system in earlier versions of both Magento Enterprise Edition and Community Edition.

A full explanation of the analysis of the root causes and additional confirmation of the research and solutions provided for both the category URLs and the products can be found in the table Magento core_url_rewrite excessively large

0
source

All Articles