繁体   English   中英

magento将自定义输入字段添加到admin中的客户帐户表单

[英]magento add custom input field to customer account form in admin

我正在尝试将自定义输入字段添加到admin中客户的帐户信息选项卡中。 我已经成功地在eav表中为我的输入创建了一个自定义属性,但是在找到如何显示我的输入方面却没有成功。 好奇的人有什么好的资源怎么做?

以上链接不再起作用。 我在http://www.excellencemagentoblog.com/customer-registration-fields-magento1-6上找到了更好的解释。 如果您只是执行第一步,则只会在管理员中添加添加的字段。

你必须告诉它使用的属性:

Mage::getModel('customer/attribute')
    ->loadByCode('customer', 'your_attrib_code')
    ->setUsedInForms(array('adminhtml_customer'))
    ->save();

为方便起见,可以将其放在标准的Magento升级脚本中(通常是最初创建属性的相同脚本,或者紧跟在其后面的脚本)。

最快的方法是创建一个php文件并通过浏览器访问它,将以下内容添加到文件中。

define('MAGENTO', realpath(dirname(__FILE__)));
ini_set('memory_limit', '32M');
set_time_limit (0);
require_once MAGENTO . '/../app/Mage.php';
Mage::app();

$newFields = array(
    'custom_attribute' => array(
        'type'              => 'text',
        'label'                => 'Customer Custom Attribute'
    )
);

$entities = array('customer');

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
foreach($newFields as $attributeName => $attributeDefs) {
    foreach ($entities as $entity) {
        $setup->addAttribute($entity, $attributeName, array(
            'position'          => 1,
            'type'              => $attributeDefs['type'],
            'label'             => $attributeDefs['label'],
            'global'            => 1,
            'visible'           => 1,
            'required'          => 0,
            'user_defined'      => 1,
            'searchable'        => 0,
            'filterable'        => 0,
            'comparable'        => 0,
            'visible_on_front'  => 1,
            'visible_in_advanced_search' => 0,
            'unique'            => 0,
            'is_configurable'   => 0,
            'position'          => 1,
        ));                
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM