Programmatically speaking, the category page will return a noRoute/404 page when the call to _initCategory
returns false.
#File: app/code/core/Mage/Catalog/controllers/CategoryController.php
if ($category = $this->_initCatagory()) {
//...
}
elseif (!$this->getResponse()->isRedirect()) {
$this->_forward('noRoute');
}
The _initCategory
method returns false for three reasons
When a category id can't be extracted from the request,
#File: app/code/core/Mage/Catalog/controllers/CategoryController.php
$categoryId = (int) $this->getRequest()->getParam('id', false);
if (!$categoryId) {
return false;
}
When the catalog/category
helper's canShow
method returns false,
#File: app/code/core/Mage/Catalog/controllers/CategoryController.php
if (!Mage::helper('catalog/category')->canShow($category)) {
return false;
}
When an observer of the catalog_controller_category_init_after
event throws an exception
#File: app/code/core/Mage/Catalog/controllers/CategoryController.php
try {
Mage::dispatchEvent(
'catalog_controller_category_init_after',
array(
'category' => $category,
'controller_action' => $this
)
);
} catch (Mage_Core_Exception $e) {
Mage::logException($e);
return false;
}
The canShow
method mentioned above returns false for three reasons.
If the category has no id,
#File: app/code/core/Mage/Catalog/Helper/Category.php
if (!$category->getId()) {
return false;
}
The category's active property is set to false
#File: app/code/core/Mage/Catalog/Helper/Category.php
if (!$category->getIsActive()) {
return false;
}
Or the category isn't in the root category list
#File: app/code/core/Mage/Catalog/Helper/Category.php
if (!$category->isInRootCategoryList()) {
return false;
}
Some quick temporary debugging code in the above files should get to the bottom of your problem.
If viewAction
method isn't being called, it means your rewrites aren't being created. If you're using Commerce Bug (my commercial Magento debugging extension) the Request tab will quickly tell you which controller action method is being called.
You can delete all the URL rewrites with in mysql:
delete from url_rewrite;
delete from catalog_url_rewrite_product_category;
After which you can use iazel extension to regenerate the rewrites.
Warning:
Editing MySQL directly can be dangerous, so try it out on a local/development server before doing this on a production server.
Best Answer
I currently use this to update the url keys of certain products: