Monday, 27 May 2019

How to Add Custom Field to Customer Address in magento 1.9

<?php
$installer = new Mage_Customer_Model_Entity_Setup('core_setup');

$installer->startSetup();

$installer->addAttribute('customer_address', 'flatnumber', array(
    'type' => 'varchar',
    'input' => 'text',
    'label' => 'Door / Flat Number',
    'global' => 1,
    'visible' => 1,
    'required' => 0,
    'user_defined' => 1,
    'visible_on_front' => 1
));
Mage::getSingleton('eav/config')
    ->getAttribute('customer_address', 'flatnumber')
    ->setData('used_in_forms', array('customer_register_address','customer_address_edit','adminhtml_customer_address'))
    ->save();
$installer->endSetup();

 ?>

No comments:

Post a Comment