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

发布于 2024-10-19 22:28:29 字数 106 浏览 3 评论 0原文

我正在尝试将自定义输入字段添加到管理员中客户的帐户信息选项卡中。我已经成功地在 eav 表中为我的输入创建了自定义属性,但未能成功找到如何使我的输入显示出来。好奇有人有关于如何做到这一点的好资源吗?

I am trying to add a custom input field to the account information tab of a customer in admin. i have successfully been able to create a custom attribute in the eav table for my input, but have been unsuccessful in finding how to make my input show up. curious of anyone has any good resources on how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

吻风 2024-10-26 22:28:29

上面的链接不再有效。我在 http://www.excellencemagentoblog.com/customer-registration 找到了更好的解释-fields-magento1-6 。如果您只执行第一步,您将只能在管理中看到添加的字段。

The above link doesn't work anymore. I found a better explanation at http://www.excellencemagentoblog.com/customer-registration-fields-magento1-6 . If you just do the first steps you will only have the added fields in the admin.

花开雨落又逢春i 2024-10-26 22:28:29

最快的方法是创建一个 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,
        ));                
    }
}

The fastest way is to create a php file and access it through browser add the following content to file.

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,
        ));                
    }
}
老娘不死你永远是小三 2024-10-26 22:28:29

您必须告诉该属性其使用的形式:

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

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

You have to tell the attribute which forms it's used in:

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

This can be put in a standard Magento upgrade script for convenience (usually the same script that originally created the attribute, or the one right after it).

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