I am trying to add a new root category on a local install of Magento CE 1.8.1, however when I press the save category button, I get the following error in the console and nothing happens on screen.
I have tried to reinstall all the core files etc but nothing seems to fix this issue.
Uncaught TypeError: Cannot read property 'split' of undefined
This is a Javascript error in the ajax routine that sends the form data to the Magento server. The code that is causing the error is
the general[path] represents the category hierarchy so a root category should always have a
but a sub category will have the id of it's parent category.
It is an odd error for you to get. Can you make sub categories successfully? Can you work out why the form submission is not setting the field general[path]? If you inspect the HTML page source of the 'add new root category page' you should see some code like this, no?
The error you are getting suggests that you don't have that line of HTML in your new root category form. (Or possibly that there is a Javascript error prior to this, about setting the category path, but start by looking for that HTML and please report back. You could add some JavaScript break points to inspect the variables and try to understand why general[path] ends up being undefined.)
The real problem
starts in
Mage_Adminhtml_Block_Catalog_Category_Tab_Attributes
In the
_prepareForm
function is a if-condition (if ($this->getAddHiddenFields())
) which ensures that the hidden fieldsgeneral[id]
andgeneral[path]
are not rendered because it always returnsfalse
.A bad solution would be to remove the if condition.
but as core changes are bad, is the new wonder what is
getAddHiddenFields()
and why does it returnfalse
?The Solution (for now):
In the database table
eav_attribute_group
search for an entry that matches the following query:and Set the
sort_order
to 1The Explanation:
The answer to my first question (what is
getAddHiddenFields()
):getAddHiddenFields()
is a magic method and returns the value of the varien object field'add_hidden_fields'
. The Value of'add_hidden_fields'
is set bysetAddHiddenFields()
inMage_Adminhtml_Block_Catalog_Category_Tabs->_prepareLayout()
.For the answer to my second question (why does it always return
false
) i created a little Debug log:Note 1: remember $defaultGroupId is initalized with 0 so the first entry of groupCollection would be set as default (Because of this the current solution is to set the defaultGroups sortOrder to 1)
Note 2: Oh look the nextmystery $group->getIsDefault() of group 3 returns FALSE (in my case is group 3 General and in the Database is_default = 1) I have not tested yet, because the current solution is currently sufficient for me.