JavaScript错误阻止添加和保存类别

JavaScript错误阻止添加和保存类别

本文介绍了Magento-JavaScript错误阻止添加和保存类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Magento CE 1.8.1的本地安装上添加新的根目录类别,但是,当我按下保存类别"按钮时,在控制台中出现以下错误,并且屏幕上没有任何反应.

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

推荐答案

真正的问题

开始于Mage_Adminhtml_Block_Catalog_Category_Tab_Attributes

_prepareForm函数中是一个if条件(if ($this->getAddHiddenFields())),它确保不呈现隐藏字段general[id]general[path],因为它总是返回false.

In the _prepareForm function is a if-condition (if ($this->getAddHiddenFields())) which ensures that the hidden fields general[id] and general[path] are not rendered because it always returns false.

一个糟糕的解决方案是删除if条件.

A bad solution would be to remove the if condition.

但是由于核心更改不好,新的疑问是getAddHiddenFields()是什么,为什么返回false吗?

but as core changes are bad, is the new wonder what is getAddHiddenFields() and why does it return false?

在数据库表eav_attribute_group中搜索与以下查询匹配的条目:

In the database table eav_attribute_group search for an entry that matches the following query:

SELECT * FROM `eav_attribute_group` WHERE default_id = 1 AND sort_order > 1;

,然后将sort_order设置为1

第一个问题的答案(什么是getAddHiddenFields()):getAddHiddenFields()是一种魔术方法,它返回varien对象字段'add_hidden_fields'的值.'add_hidden_fields'的值由Mage_Adminhtml_Block_Catalog_Category_Tabs->_prepareLayout()中的setAddHiddenFields()设置.

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 by setAddHiddenFields() in Mage_Adminhtml_Block_Catalog_Category_Tabs->_prepareLayout().

对于第二个问题的答案(为什么它总是返回false),我创建了一个调试日志:

For the answer to my second question (why does it always return false) i created a little Debug log:

# Debug log of Mage_Adminhtml_Block_Catalog_Category_Tabs->_prepareLayout()
init $defaultGroupId with: 0
check group 157 is 0 or isDefault //Note 1 (see further down below)
  if ($defaultGroupId(0) == 0 or $group->getIsDefault():false)
    set $defaultGroupId to 157
check group 3 is 0 or isDefault
  if ($defaultGroupId(157) == 0 or $group->getIsDefault():false) //Note 2 (see further down below)
check group 10 is 0 or isDefault
  if ($defaultGroupId(157) == 0 or $group->getIsDefault():false)
[...]

process groupId 157
    groupId 157 has no attributes
    if (!$attributes) { continue; }

process groupId 3
    groupId 3 has attributes
    if (!$attributes) { continue; }
    $active  = $defaultGroupId == $group->getId();
    setAddHiddenFields($active (false)))

process groupId 10
    groupId 10 has attributes
    if (!$attributes) { continue; }
    setAddHiddenFields($active (false)))
[...]

注意1: 记住$ defaultGroupId的初始值为0,因此groupCollection的第一个条目将设置为默认值(因此,当前解决方案是为了将defaultGroups sortOrder设置为1)

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)

注意2: 哦,看看第3组的下一个谜团$ group-> getIsDefault()返回FALSE(在我的情况下是第3组General,在数据库中is_default = 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.

这篇关于Magento-JavaScript错误阻止添加和保存类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 01:39