我怎样才能得到我的自定义后端的Magento客户复选框属性救我的选择? [英] How can I get my custom backend Magento Customer Checkbox Attribute to save my selection?

查看:222
本文介绍了我怎样才能得到我的自定义后端的Magento客户复选框属性救我的选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Magento的CE 1.5.1.0

Magento CE 1.5.1.0

我试图创建一个Magento的模块安装文件一个新的客户属性。我有它工作正常进行文本输入,但我想一个复选框添加到客户账户信息的客户信息页面的部分,在管理后台。它不应该是在前端或编辑由客户可见。我只是希望它是一个布尔值。

I'm trying to create a new customer attribute on the installation file for a Magento Module. I have it working fine for text inputs, but I would like to add a checkbox to the customer "Account Information" section of the "Customer Information" page, in the admin backend. It shouldn't be visible on the frontend or editable by the customer. I just want it to be a boolean value.

我有属性出现在后台,在正确的地方,它默认为被选,这是很好的,但是当我点击保存并继续编辑按钮(或拯救客户),我重定向主管理仪表板。当我再次管理客户我看到我选中复选框未存储,并再次默认。

I have the attribute appearing on the backend, in the correct place, and it defaults to being unselected, which is good, but when I click "Save and continue edit" button (or "save customer"), I am redirected to the main Admin Dashboard. When i manage the customer again I see that me checking the checkbox has not been stored, and it's default again.

在code我目前有(乔纳森日的回答带到这个问题:<一href=\"http://stackoverflow.com/questions/5961290/adding-attributes-to-customer-entity/5962237#5962237\">Adding归因于客户实体)是这样的:

The code I currently have (taken from Jonathan Day's answer to this question: Adding attributes to customer entity ) is this:

$installer = $this;
$installer->startSetup();

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$entityTypeId     = $setup->getEntityTypeId('customer');
$attributeSetId   = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);

$setup->addAttribute('customer', 'ignore_ip_notifications', array(
    'input'         => 'checkbox',
    'type'          => 'int',
    'label'         => 'Ignore IP Notifications',
    'visible'       => 1,
    'user_defined'  => 0,
    'required'      => 0,
    'source'        => 'eav/entity_attribute_source_boolean'
));

$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'ignore_ip_notifications',
'998'  //overwritten sort_order
);

$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'ignore_ip_notifications');
$oAttribute->setData('used_in_forms', array('adminhtml_customer'));
$oAttribute->setData('sort_order', 998);
$oAttribute->save();

$installer->endSetup();

如前所述,属性出现,因为它应该,但重定向到仪表板,而不是保存。

As mentioned, the attribute appears as it should but redirects to the dashboard, rather than save.

任何帮助将非常AP preciated。

Any help would be very much appreciated.

IB

推荐答案

我不是100%肯定,但您可能需要为后端的定义以及字段集,这样的:

I'm not 100% sure, but you might need fieldsets defined for backend as well, like this:

<fieldsets>
             <customer_account>
                 <attribute_code>
                    <create>1</create>
                    <update>1</update>
                </attribute_code>
             <customer_account>
</fieldsets>

这篇关于我怎样才能得到我的自定义后端的Magento客户复选框属性救我的选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆