Working on a new Magento store, I got this error while rebuilding the Catalog URL Rewrites index:
! An error occurred while saving the URL rewrite
After the usual Google searches, I came across this post, which proved to be the answer to my problem: http://www.magentocommerce.com/boards/main.php/viewthread/198534/#t334426
Turns out there’s a conflict introduced by the installation of the osCommerce Migration Extension. However, the post wasn’t exactly clear on which code to change, so I figured I’d post a little more on the issue.
First, I moved all of the osCommerce code out of app/code/core/Mage and into app/code/local/Mage. I should point out, though, that I had already done that even before I ran into this problem because I ran into several issues with the import process that I was (cautiously) optimistic that I could actually fix, as well as several things that I wanted to change (for example, my import source had categories that contained embedded HTML I wished to strip out – and I had several thousand categories …)
The file we need to edit is Mage/Oscommerce/Model/Mysql4/Catalog/Url.php. In that file, we find the Mage_Oscommerce_Model_Mysql4_Catalog_Url, which extends Mage_Catalog_Model_Resource_Eav_Mysql4_Url:
class Mage_Oscommerce_Model_Mysql4_Catalog_Url extends Mage_Catalog_Model_Resource_Eav_Mysql4_Url { protected function _getCategories($categoryIds, $storeId = null, $path = null) { $isActiveAttribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_category', 'is_active'); $categories = array(); |
Basically, all the post wants us to do is short circuit the _getCategories function by returning its parents’ version instead.
class Mage_Oscommerce_Model_Mysql4_Catalog_Url extends Mage_Catalog_Model_Resource_Eav_Mysql4_Url { protected function _getCategories($categoryIds, $storeId = null, $path = null) { return parent::_getCategories(); $isActiveAttribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_category', 'is_active'); $categories = array(); |
Note: Please don’t confuse this with a “good, permanent” solution. This is a nice way to be able to continue to refine my import using osCommerce Migration, and be minimally invasive. Once I have this thing working properly, I will simply remove the osCommerce Migration Extension from my site – once I’m live, I won’t need it any more.
Thanks for this. I ended up uninstalling it — it’s caused me much too many headaches. I’ve been developing my own extension that actually works. Phew.
thanks, very much thanks, this code is the solution for my problem.
Best regards
George
A million thanks!! For taking the time to write it step by step. This solution totally helped me. 🙂
Thanks so much for posting this. This fixed all of my URLS. I do have one issue though. I did get my catalog to reindex after making this change, but I when made a change to the following and it went back to the reindexing error
System > Configuration > Catalog > Search Engine Optimizations > Use Categories Path for Product URLs
Any idea on what I can do to fix this again?
I’m running on 1.6.0
Thanks for Posting. It saved a lot of time. Otherwise i might have to spend a lot of time to figure it out and resolve.
Fixed issue on magento 1.6.0.0 as well as on magento 1.6.2.0.
http://w3sols.com
We provide Customize magento solutions.