Try the Demo

Magento

eCommerce Software for Online Growth

Magento Forum

Our new hosted solution for small & emerging businesses
   
Page 1 of 2
URL Rewrite Index Error For 1.4.1.0
 
Ashley
Member
 
Total Posts:  50
Joined:  2008-07-23
 

Hi,

We have upgraded to 1.4.1.0 and have problems with the re-index URL rewrites. We have 56 stores setup in magento and the problem appears to be related this. For every product a new URL rewrite is created for every store and the index process seems to work for 1 store only but the second it starts to index the next store we get the error saving URL rewrites message.

With some debugging and database monitoring, the actual exception being thrown is complaining about a duplicate entry in the url rewrites table but the data is being saved in the database for the record implying that mySQL is not throwing the error because the data would not save if this was the case. We have also noticed that is not a duplicate entry as the primary key is made up of id_path, is_system, & store_id and there are no records matching this even though this error is being thrown.

I have simply commented out the exception being thrown, re-indexed the URL’s and now everything seems to function correctly. I know this is not the fix but it has worked for us temporarily and we know have nice URL’s that work for every product in every store.

I have seen other comments about URL indexing with multiple stores causing problems in this version and was wondering if anybody else has come across this or found a proper fix yet?

The line I commented out to actually get the indexer to work and finish was line 253 in app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Url.php

try {
    $this
->_getWriteAdapter()->insert($this->getMainTable(), $rewriteData);
catch (Exception $e{
    
//var_dump($e); die();
    //Mage::throwException(Mage::helper('catalog')->__('An error occurred while saving the URL rewrite.'));
}

If you uncomment the var_dump line and run the indexer you will see the error being thrown complaining about the duplicate entry that is not a duplicate entry.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jim Heng
Jr. Member
 
Total Posts:  1
Joined:  2010-04-24
 

That’s much help for me.
I looking a lot solution but not much help

I got 2 store and 3 view and I am 100% sure i not duplicate any item url key but I getting this error.
Thanks Ashley, that the only way we can do for now.

Perhaps have better solution

 
Magento Community Magento Community
Magento Community
Magento Community
 
bluescrubbie
Jr. Member
 
Total Posts:  21
Joined:  2009-10-01
 

Bump!
Hey, Varien!  This is requiring core hacks for anyone with multiple stores!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Marketiger
Member
 
Total Posts:  46
Joined:  2010-04-27
 
Ashley - 08 July 2010 03:32 AM

Hi,

We have upgraded to 1.4.1.0 and have problems with the re-index URL rewrites. We have 56 stores setup in magento and the problem appears to be related this. For every product a new URL rewrite is created for every store and the index process seems to work for 1 store only but the second it starts to index the next store we get the error saving URL rewrites message.

With some debugging and database monitoring, the actual exception being thrown is complaining about a duplicate entry in the url rewrites table but the data is being saved in the database for the record implying that mySQL is not throwing the error because the data would not save if this was the case. We have also noticed that is not a duplicate entry as the primary key is made up of id_path, is_system, & store_id and there are no records matching this even though this error is being thrown.

I have simply commented out the exception being thrown, re-indexed the URL’s and now everything seems to function correctly. I know this is not the fix but it has worked for us temporarily and we know have nice URL’s that work for every product in every store.

I have seen other comments about URL indexing with multiple stores causing problems in this version and was wondering if anybody else has come across this or found a proper fix yet?

The line I commented out to actually get the indexer to work and finish was line 253 in app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Url.php

try {
    $this
->_getWriteAdapter()->insert($this->getMainTable(), $rewriteData);
catch (Exception $e{
    
//var_dump($e); die();
    //Mage::throwException(Mage::helper('catalog')->__('An error occurred while saving the URL rewrite.'));
}

If you uncomment the var_dump line and run the indexer you will see the error being thrown complaining about the duplicate entry that is not a duplicate entry.

This fixed my problem - thank you very much!

 
Magento Community Magento Community
Magento Community
Magento Community
 
mfoillard
Member
 
Total Posts:  64
Joined:  2008-08-04
 

same here, it solves the catalog url reindex problem with multiple stores

 
Magento Community Magento Community
Magento Community
Magento Community
 
matthewetaft
Jr. Member
 
Total Posts:  3
Joined:  2009-07-17
 

This solved my problem.  Afterwards, I removed the comment characters and re-indexed everything, and the error was gone.  Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
nicolasconsulting
Jr. Member
 
Total Posts:  13
Joined:  2009-12-17
 

Hello,

My Catalog URL Rewrites are still processing.
The solution above did not work for me.
Any other solutions ?

Thanks

Nick

 
Magento Community Magento Community
Magento Community
Magento Community
 
legstherapy
Jr. Member
 
Total Posts:  5
Joined:  2010-08-03
 

I have “Index product and categories URL rewrites” still stuck on “processing”

Any help will be appreciated

 
Magento Community Magento Community
Magento Community
Magento Community
 
meeeearcus
Member
 
Total Posts:  57
Joined:  2008-07-01
 

Looks like this has been listed as fixed in 1.5.0. Going to give it some time in the wild before suggesting upgrades for my clients.

 
Magento Community Magento Community
Magento Community
Magento Community
 
where_s_gary
Jr. Member
 
Total Posts:  12
Joined:  2009-01-13
 

The solution worked for fixing the url rewrite error. Thanks. However, my new products that i added is not showing up after the URL re-write.

Any new fix? is it worth upgrading to 1.5?

Gary

 
Magento Community Magento Community
Magento Community
Magento Community
 
rornelas
Jr. Member
 
Total Posts:  4
Joined:  2008-06-09
 

Which version of Magento Professional resolves this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tufail
Jr. Member
 
Total Posts:  2
Joined:  2008-10-16
Islamabad
 

thanks, It’s also worked for me on Magento 1.4.1.1

 
Magento Community Magento Community
Magento Community
Magento Community
 
dtrain
Jr. Member
 
Total Posts:  8
Joined:  2010-04-30
 

I recently created a new store in a multi-store 1.4.2 environment in which the same product would be listed in multiple categories. I immediately ran into the same URL Re-indexing error as reported above. Rather than simply commenting out the exception I decided to explore a bit. The problem in my case was definitely related to the fact that the same product was listed in multiple sub-categories. It seems that a problem exists in the generatePath function of /app/code/core/Mage/Catalog/Model/Url.php. At around line 780 the following code exists:

if ($category && $category->getLevel() > 1{
             
return \'product/\' $product->getId() . \'/\' $category->getId();
            
}
            
return \'product/\' $product->getId();

It seems that $category->getLevel() fails to return a value, therefore the logic falls through and the id_path is created as product/productid for all records inserted into core_url_rewrite where the same product is found in multiple categories for the same store! Thus violating the UNQ_PATH constraint. Rather than modifying several core files to address this, I took the following expedient hack:

//if ($category && $category->getLevel() > 1) {
        if ($category && (count(explode(\'/\'$category->getPath())) - 1) > 1){
                
return \'product/\' $product->getId() . \'/\' $category->getId();
            
}
            
return \'product/\' $product->getId();

This fixed my problem. Unfortunately, core_url_rewrite has one record for every category to which a product is assigned including the root. This is expected behavior but makes for a long running index process. I hope the *bug* and the index performance is addressed in 1.5.

Alternative to changing the core file, you can always remove the unique constraint for UNQ_PATH via phpMyAdmin or similar. However, there may be unforeseen consequences in doing so. This was my temporary fix before diving into the code. I have 6 stores with a total of 60K skus and while the index was changed I didn\’t see any problems, but your mileage may vary. smile

Hope this helps someone else.

Cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
stefaanva
Jr. Member
 
Total Posts:  4
Joined:  2010-12-21
 

Hi,

I am still experiencing this problem in 1.5.1. This particular index “url rewriting” stays in the status “processing”. However with the same version some days ago, it finished ... Anybody has a solution for this?

Tx!

Regards,
Stefaan

 
Magento Community Magento Community
Magento Community
Magento Community
 
Zadakyel
Jr. Member
 
Total Posts:  4
Joined:  2010-07-02
 
dtrain - 25 March 2011 01:23 AM

I recently created a new store in a multi-store 1.4.2 environment in which the same product would be listed in multiple categories. I immediately ran into the same URL Re-indexing error as reported above. Rather than simply commenting out the exception I decided to explore a bit. The problem in my case was definitely related to the fact that the same product was listed in multiple sub-categories. It seems that a problem exists in the generatePath function of /app/code/core/Mage/Catalog/Model/Url.php. At around line 780 the following code exists:

if ($category && $category->getLevel() > 1{
             
return \'product/\' $product->getId() . \'/\' $category->getId();
            
}
            
return \'product/\' $product->getId();

It seems that $category->getLevel() fails to return a value, therefore the logic falls through and the id_path is created as product/productid for all records inserted into core_url_rewrite where the same product is found in multiple categories for the same store! Thus violating the UNQ_PATH constraint. Rather than modifying several core files to address this, I took the following expedient hack:

//if ($category && $category->getLevel() > 1) {
        if ($category && (count(explode(\'/\'$category->getPath())) - 1) > 1){
                
return \'product/\' $product->getId() . \'/\' $category->getId();
            
}
            
return \'product/\' $product->getId();

This fixed my problem. Unfortunately, core_url_rewrite has one record for every category to which a product is assigned including the root. This is expected behavior but makes for a long running index process. I hope the *bug* and the index performance is addressed in 1.5.

Alternative to changing the core file, you can always remove the unique constraint for UNQ_PATH via phpMyAdmin or similar. However, there may be unforeseen consequences in doing so. This was my temporary fix before diving into the code. I have 6 stores with a total of 60K skus and while the index was changed I didn\’t see any problems, but your mileage may vary. smile

Hope this helps someone else.

Cheers

This method works for me i’m using Magento 1.5.1.0, installed on a windows server 2008 enviroment.

Before geting this code works correctly, i made a change erasing the backslashes \ form the code and after do that the code let magento
to finish reindexing CATALOG URL REWRITES in less time.

I left the code that i used.

/*if ($category && $category->getLevel() > 1) {
                return 'product/' . $product->getId() . '/' . $category->getId();
            }
            return 'product/' . $product->getId();*/
             if ($category && (count(explode('/'$category->getPath())) - 1) > 1){
                
return 'product/' $product->getId() . '/' $category->getId();
            
}
            
return 'product/' $product->getId();
        
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sylvain_Raye
Sr. Member
 
Avatar
Total Posts:  91
Joined:  2008-12-29
Zurich - Switzerland
 

If like me you have a problem by reindexing the url rewrites. I invite you to check if you don’t have a conflict with an other module which overwrites or use the class Mage_Catalog_Model_Resource_Eav_Mysql4_Url

It’s the case if you use the OSCommerce module for Magento like me. There is a conflict, the database query doesn’t ask to load the level of a category. And so, in the core code, $category->getLevel() is empty.

The solution with oscommerce is to do return parent::_getCategories(...) at the very first line of the same method name of the class Mage_Oscommerce_Model_Mysql4_Catalog_Url or remove the class completely (php file and confix.xml)

Regards
Sylvain

 Signature 

Visit my free Magento Connect Extensions: Joomla Integration - Username Integration - JS/CSS Optimization - Zopim Chat Integration - and more

IT development manager for rissip.com - the marketplace platform for free and paid online courses.

Magento Certified Developer #27785766

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 1 of 2
 
© Copyright Magento Inc.
Privacy Policy|Terms of Service
Magento Community Count
819302 users|1530 users currently online|519457 forum posts