2

This question already has an answer here:

Hello a i need i add new filed admin customer creation form, the field name is VIP, i search so many links related to my requirement but not in magento(1.9).

can you please give some idea related to my requirement.

Thank you

marked as duplicate by Arunendra, Manashvi Birla, Klettseb, 7ochem, liyakat Sep 30 '15 at 12:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

You can use below script to create customer attribute

<?php
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();

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

$installer->addAttribute('customer', 'vip', array(
    'input'         => 'text',
    'type'          => 'varchar',
    'label'         => 'VIP',
    'visible'       => 1,
    'required'      => 0,
    'user_defined'  => 1,
));

$installer->addAttributeToGroup(
    $entityTypeId,
    $attributeSetId,
    $attributeGroupId,
    'vip',
    '100'
);

$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'vip');

$oAttribute->setData('used_in_forms', array('adminhtml_customer','customer_account_edit')); 
$oAttribute->save();

$installer->endSetup();

You can change input type as per your requirement.

  • In that file I need to enter this code – Francisco Javier Lorenzo Berna Sep 30 '15 at 10:38
  • 1
    You can create a module and add this code in setup script or just create one sample attribute.php file on root paste above code but before that code add require_once("app/Mage.php"); Mage::app(); in file and run in browser directly. It will create new attribute in system. – Akhilesh Patel Sep 30 '15 at 10:52
  • and if you need to remove a field change much code Thanks for everything – Francisco Javier Lorenzo Berna Oct 1 '15 at 8:32
2

You can use below script to create customer attribute visible in admin customer creation form

$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup(); 
$installer->addAttribute("customer", "vip",  array(
    "type"     => "varchar",
    "backend"  => "",
    "label"    => "VIP",
    "input"    => "text",
    "source"   => "",
    "visible"  => true,
    "required" => false,
    "default" => "",
    "frontend" => "",
    "unique"     => false,
    "note"       => "" 
));

$attribute   = Mage::getSingleton("eav/config")->getAttribute("customer", "vip");         
$used_in_forms=array(); 
$used_in_forms[]="adminhtml_customer";
$attribute->setData("used_in_forms", $used_in_forms)
          ->setData("is_used_for_customer_segment", true)
          ->setData("is_system", 0)
          ->setData("is_user_defined", 1)
          ->setData("is_visible", 0)
          ->setData("sort_order", 100);
$attribute->save();
$installer->endSetup();

You can change input type as per your requirement.

Not the answer you're looking for? Browse other questions tagged or ask your own question.