致命错误:Magento 将列添加到管理客户网格

发布于 2024-12-15 08:34:00 字数 2058 浏览 2 评论 0原文

我想向管理客户网格添加一列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')

它工作正常,并且列被添加到网格中,但是,当我尝试过滤时基于新添加的列的记录,出现错误 Mage EAV Error

当我检查相应的错误报告时,它说:

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
Mage EAV 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

星星的轨迹 2024-12-22 08:34:00

我已经找到了解决我所面临问题的方法。
在我的头撞墙上几个小时之后。

实际上,对列使用任何数据类型都没有问题。所以,问题不在表中。

我检查了所有相关文件。最后,找到了问题所在。
实际上,我是对的,直到:

$this->addColumn('is_onHold', array(
        'header'  => Mage::helper('customer')->__('On Hold?'),
        'width'   => '120',
        'index'   => 'is_onHold',
        'type'    => 'options',
        'options' => array('1' => 'Yes', '0' => 'No')
));

但是

->addAttributeToSelect('is_onHold')

,我认为当您使用上述方法时,您需要对 Mage_Customer_Model_Entity_Customer->_getDefaultAttributes() 和您的列进行一项额外的更改...

就像我所做的那样:

return array(
            'entity_type_id',
            'attribute_set_id',
            'created_at',
            'updated_at',
            'increment_id',
            'store_id',
            'website_id',
            'is_onHold',
            'hold_till'
        );

数组中的最后 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:

$this->addColumn('is_onHold', array(
        'header'  => Mage::helper('customer')->__('On Hold?'),
        'width'   => '120',
        'index'   => 'is_onHold',
        'type'    => 'options',
        'options' => array('1' => 'Yes', '0' => 'No')
));

and

->addAttributeToSelect('is_onHold')

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 :

return array(
            'entity_type_id',
            'attribute_set_id',
            'created_at',
            'updated_at',
            'increment_id',
            'store_id',
            'website_id',
            'is_onHold',
            'hold_till'
        );

Last 2 in the array are columns added by me...

Hope this will help someone...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文