Magento Forum

   
Cannot Add Category
 
smoothliquid
Jr. Member
 
Total Posts:  1
Joined:  2008-11-29
 

Perhaps this will help someone with the same problem. I’m not sure if this defect appears because of something weird in my webserver environment (i.e. Apache or PHP config), but I receive a 404 error when trying to Add a root or subcategory. I figured out how to fix it with a code change and I filed a bug report.

Here is an excerpt of the report:

When I attempt to add a category or subcategory using the Add Root Category or Add Subcategory buttons, I get a 404 error. I’ve seen multiple issues on here regarding adding categories, but I didn’t see anyone mention a page not found error. I did figure out why I’m receiving the error…

When I click one of those buttons, a URL is constructed using addNew(), but apparently there needs to be a slash appended to the end of the URL. The problem is in the following line in the [removed]
url+= ‘parent/’+tree.currentNodeId;
To make it work on my webserver, I appended a / to the end, resulting in:
url+= ‘parent/’+tree.currentNodeId+’/’;

I did this by modifying the following file:
app/design/adminhtml/default/default/template/catalog/category/tree.phtml

The new function looks like this:
function addNew(url, isRoot)
{
if (isRoot) {
tree.currentNodeId = tree.root.id;
}
tree.addNodeTo = tree.currentNodeId;

if (/store\/\d+/.test(url)) {
url = url.replace(/store\/\d+/, “store/” + tree.storeId);
}
else {
url+= “store/” + tree.storeId + “/”;
}

url+= ‘parent/’+tree.currentNodeId+’/’;
updateContent(url);
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
vito059
Jr. Member
 
Total Posts:  4
Joined:  2009-01-19
 

Thanks for this. I have spent few days trying to figure this problem.

It appears to be working well now for me.

Regards!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top