5

This question already has an answer here:

I've truncated the core_url_rewrite table with about 5000000 records. After that I run the Catalog URL Rewrite Indexer which created 1782612 records. Then I run it again and the table had 2251930 records. So, every time I run the indexer, I get more records in the table. Does anyone know why? Thanks

marked as duplicate by Moose, Marius, benmarks Apr 26 '14 at 15:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4

I also asked a similar question a while back:

Magento core_url_rewrite table excessively large

I've managed to stabalize the issue as follows:

Step 1: Rewrite the Catalog URL model (Using your own module: How To)

Note: If you overwrite the core file without using a rewrite this will render your instance of Magento incapable of future upgrades.

As per Jahnni's solution on the MagentoCommerce boards, app/code/core/Mage/Catalog/Model/Url.php around line 807

From:

if ($product->getUrlKey() == '' && !empty($requestPath)
   && strpos($existingRequestPath, $requestPath) === 0
) 

To:

if (!empty($requestPath)
           && strpos($existingRequestPath, $requestPath) === 0
) 

Step 2: Truncate

Truncate the core_url_rewrite table

Step 3: Reindex & Flush Caches

Initiate the re-indexing process on Core URL Rewrites. Thereafter, you'll want to flush the Magento cache & storage cache.

SystemCache ManagementFlush Magento Cache

SystemCache ManagementFlush Cache Storage

Voila, you're all set. You'll notice if you re-run the indexer, the table should stay constant in size (unless you've added more products inbetween or if you have duplicate category names).

  • 2
    A word of warning: if you truncate core_url_rewrite you are deleting all of your custom rewrites as well as the system ones - these won't be regenerated by the subsequent reindex and will be lost permanently! – Doug McLean Jul 17 '15 at 16:08
  • True. instead delete the entitytype="product" (for products alone) – arvindwill Jun 16 at 9:40
3

I guess there are several reasons why this may happen. One of the more obvious is when you have several products with the same URL key.

Given you have two products both named "Test" with both products having the same URL key "test". Magento will create two URL rewrites: one for test.html and one for test-2.html. If you re-run the Rewrite Indexing process, Magento will start creating a further redirect for the test-2.html URL and so on. As you can guess that's not a wanted behaviour but it happens pretty often, especially with stores having configurable products with many simple products sharing the same name (e.g. clothes with different sizes and colors).

To dive deeper into this problem and find the cause for your growing URL rewrite table we would need more detail, I'm afraid.

Not the answer you're looking for? Browse other questions tagged or ask your own question.