I tried everything only thing that worked was to flush absolutely everything and run indexing on all. Logged out and back in again and it was fine.
I also ran magento-cleanup.php - available here: http://www.magentocommerce.com/wiki/groups/227/resetting_file_permissions
Very frustrating when these things happen, but good to know for next time.
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.\’));
}
I hope it\’s work for you.
This solution worked for me after trying absolutely every other suggestion out there with no luck. I have no idea what caused the problem in the first place, it just started happening.
No amount of flushing, re-indexing and deleting cache folders had made any difference.
The only problem with this solution is that it changes a core Magento file, so when you update versions the error will probably crop up again. Also, that function is presumably there for a good reason, is it a good idea to just delete it?
Anyway, as a short term solution I’ll take it until someone comes up with a proper fix.
Why did I ever decide to start building Magento sites? For every step that goes right, at least three go wrong.
Guys. Commenting exception - it’s not a solution! Rewrite system on your stores still works wrong! Go to the database and open table core_url_rewrite. You don’t find there rewrite records with category paths for some products or even any records for some products. Rewrite engine still fails with errors, you just don’t see it.
Don’t make mistakes.
Exactly, commenting out the fact that it is throwing an error just means it doesnt throw the error any more. It’s still not doing it properly, now it just isn’t telling you so.
In older version it looks like it just dumped the error (somewhere) but at least in 1.6 it dumps the reason to a file.
Look in /var/log/ and you should have an exception.log file that it will dump the reason it is erroring to.
try { $adapter->insert($this->getMainTable(), $rewriteData); } catch (Exception $e) { // Bug - the category_id is set to null when the category has a level <= 1 // So if our product is in 2 differents level 1 categories, the indexer crashes if ($rewriteData[\'category_id\'] != null) { Mage::logException($e); Mage::throwException(Mage::helper(\'catalog\')->__(\'An error occurred while saving the URL rewrite\')); } }
After trying all the suggestion, i just truncated the table core_url_rewrite and then reindexed from Admin panel.
It worked perfectly in version1.6.1.0
Ran into this aswell. Problem occurred after deleting some store views.
Thnx to previous post that had the hint :
// Bug - the category_id is set to null when the category has a level <= 1
// So if our product is in 2 differents level 1 categories, the indexer crashes
Fix : I just went into system / configuration / manage stores and edit the default store view. Put sorting on 1 or higher ( just not the default 0 ) and save. Reindex, ( without error this time ) and once done, go back and put it the way it was.