magento 添加會員註冊字段

以magento1.9.3作爲例子
添加以下代碼到magento根目錄,運行.
這裏寫圖片描述

<?php
define('MAGENTO', realpath(dirname(__FILE__)));
ini_set('memory_limit', '32M');
set_time_limit (0);
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'       => 1,
    'required'      => 1,
    'user_defined'  => 1,
));

$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);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章