致命错误:Magento 将列添加到管理客户网格
我想向管理客户网格添加一列is_onHold(customer_entity 表中有一个名为is_onHold、tinyint(1) {想要存储布尔值}的列)。
我尝试了来自以下位置的 Fabrizio d 解决方案:Magento - 将列添加到客户网格,但是,当尝试根据添加的列过滤结果时,它会给出致命错误。
我在 _prepareColumns(): 中添加了以下代码,
$this->addColumn('is_onHold', array(
'header' => Mage::helper('customer')->__('On Hold?'),
'width' => '150',
'index' => 'is_onHold',
'type' => 'options',
'options' => array(
1 => 'Yes',
0 => 'No',
)
));
并在 _prepareCollection(): 中添加了以下代码:
->addAttributeToSelect('is_onHold')
它工作正常,并且列被添加到网格中,但是,当我尝试过滤时基于新添加的列的记录,出现错误
当我检查相应的错误报告时,它说:
a:5:{i:0;s:34:"Invalid attribute name: is_onHold.";i:1;s:5418:"#0 E:\wamp\www\magePrj\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(1166): Mage::exception('Mage_Eav', 'Invalid attribu...')
1 E:\wamp\www\magePrj\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(1255): Mage_Eav_Model_Entity_Collection_Abstract->_addAttributeJoin('is_onHold', 'inner')
2 E:\wamp\www\magePrj\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(292): Mage_Eav_Model_Entity_Collection_Abstract->_getAttributeConditionSql('is_onHold', Array, 'inner')
3 E:\wamp\www\magePrj\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(312): Mage_Eav_Model_Entity_Collection_Abstract->addAttributeToFilter('is_onHold', Array)
4 E:\wamp\www\magePrj\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php(449): Mage_Eav_Model_Entity_Collection_Abstract->addFieldToFilter('is_onHold', Array)
这是因为我正在尝试使用类型选项布尔列? 我不确定我做错了什么......
I wanted to add a column to Admin Customer Grid is_onHold (there is column in customer_entity table named is_onHold, tinyint(1) {want to store boolean value}).
I tried Fabrizio d solution from : Magento - Add column to customer grid, but, it's giving fatal error when trying to filter result based on the column added.
I added following code in _prepareColumns():
$this->addColumn('is_onHold', array(
'header' => Mage::helper('customer')->__('On Hold?'),
'width' => '150',
'index' => 'is_onHold',
'type' => 'options',
'options' => array(
1 => 'Yes',
0 => 'No',
)
));
and following code in _prepareCollection():
->addAttributeToSelect('is_onHold')
It works perfectly, and column is added to the grid, but, when I try to filter the record based on newly added column, I get error
when I checked the corresponding error report, it says:
a:5:{i:0;s:34:"Invalid attribute name: is_onHold.";i:1;s:5418:"#0 E:\wamp\www\magePrj\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(1166): Mage::exception('Mage_Eav', 'Invalid attribu...')
1 E:\wamp\www\magePrj\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(1255): Mage_Eav_Model_Entity_Collection_Abstract->_addAttributeJoin('is_onHold', 'inner')
2 E:\wamp\www\magePrj\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(292): Mage_Eav_Model_Entity_Collection_Abstract->_getAttributeConditionSql('is_onHold', Array, 'inner')
3 E:\wamp\www\magePrj\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(312): Mage_Eav_Model_Entity_Collection_Abstract->addAttributeToFilter('is_onHold', Array)
4 E:\wamp\www\magePrj\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php(449): Mage_Eav_Model_Entity_Collection_Abstract->addFieldToFilter('is_onHold', Array)
Is this because I am trying to use type options for a boolean column?
I am not sure what I am doing wrong...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经找到了解决我所面临问题的方法。
在我的头撞墙上几个小时之后。
实际上,对列使用任何数据类型都没有问题。所以,问题不在表中。
我检查了所有相关文件。最后,找到了问题所在。
实际上,我是对的,直到:
但是
,我认为当您使用上述方法时,您需要对 Mage_Customer_Model_Entity_Customer->_getDefaultAttributes() 和您的列进行一项额外的更改...
就像我所做的那样:
数组中的最后 2 列是我添加的列...
希望这会对某人有所帮助...
I've found the solution to the problem I was facing.
After banging my head against the wall for hours.
Actually, there was nothing wrong with using any data type for column. So, the problem was not in the table.
I checked all related files. And, finally, found where the problem was.
Actually, I was right till:
and
But, I think when you use above method, you need to make one additional change to Mage_Customer_Model_Entity_Customer->_getDefaultAttributes() and your columns there...
like I did :
Last 2 in the array are columns added by me...
Hope this will help someone...