2011-08-18 68 views
0

Magento CE 1.5.1.0如何获得自定义后端Magento客户复选框属性以保存我的选择?

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

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

我现在有(乔纳森日的回答这个问题采取:Adding attributes to customer entity)的代码是这样的:

$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(); 

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

任何帮助将非常感激。

IB

回答

0

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

<fieldsets> 
      <customer_account> 
       <attribute_code> 
        <create>1</create> 
        <update>1</update> 
       </attribute_code> 
      <customer_account> 
</fieldsets> 
相关问题