天天看点

magento 添加会员注册字段

以magento1.9.3作为例子

添加以下代码到magento根目录,运行.

magento 添加会员注册字段
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
ini_set('memory_limit', '32M');
set_time_limit ();
require_once MAGENTO . '/app/Mage.php';

Mage::app();

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->startSetup();

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

$setup->addAttribute('customer', 'mobile', array(
    'input'         => 'text',
    'type'          => 'text',
    'label'         => 'Mobile',
    'visible'       => ,
    'required'      => ,
    'user_defined'  => ,
));

$setup->addAttributeToGroup(
 $entityTypeId,
 $attributeSetId,
 $attributeGroupId,
 'mobile',
 '999'  //sort_order
);


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

$oAttribute->save();
$re = $setup->endSetup();
var_dump($re);