Add Customer Attributes to Magento

define('PATH_TO_MAGENTO', ''); require_once PATH_TO_MAGENTO . 'app/Mage.php'; Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $prefix = Mage::getConfig()->getTablePrefix(); $entityTypeID = 1; $attributes = array( array("attributeCode" => 'address', "attributeTitle" => 'Address', "inputType" =>'text', "backendType" => 'varchar' ), array("attributeCode" => 'state', "attributeTitle" => 'State', "inputType" =>'text', "backendType" => 'varchar' ), array("attributeCode" => 'postcode', "attributeTitle" => 'Postcode', "inputType" =>'text', "backendType" => 'varchar' ), array("attributeCode" => 'website', "attributeTitle" => 'Website', "inputType" =>'text', "backendType" => 'varchar' ) ); foreach ($attributes as $key=>$attribute) { $attributeCode = $attribute["attributeCode"]; $backendType = $attribute["backendType"]; $inputType = $attribute["inputType"]; $attributeTitle = $attribute["attributeTitle"]; $query = " INSERT INTO `" . $prefix . "eav_attribute` SET `attribute_id` =NULL, `entity_type_id` = $entityTypeID, `attribute_code` = '$attributeCode', `attribute_model` =NULL, `backend_model`=NULL, `backend_type` ='$backendType', `backend_table` = NULL, `frontend_model` =NULL, `frontend_input` = '$inputType', `frontend_label` = '$attributeTitle', `frontend_class` = NULL, `source_model` = NULL, `is_required` = 0, `is_user_defined` = 0, `default_value` = NULL, `is_unique` = '0', `note`= '' "; $write = Mage::getSingleton('core/resource')->getConnection('core_write'); $write->query($query); $attributeId = $write->lastInsertId(); if ($attributeId) { $query = " INSERT INTO `" . $prefix . "customer_eav_attribute` SET `attribute_id` = '$attributeId' , `is_visible` ='1' , `input_filter` = NULL , `multiline_count` = 1 , `validate_rules` = NULL , `is_system` = '0' , `sort_order`= '50', `data_model` = NULL "; $write->query($query); $query = " INSERT INTO `" . $prefix . "eav_entity_attribute` SET `entity_attribute_id` = NULL , `entity_type_id` = '1' , `attribute_set_id` ='1' , `attribute_group_id` = '1' , `attribute_id` = $attributeId , `sort_order`='50' "; $write->query($query); $query = " INSERT INTO `" . $prefix . "customer_form_attribute` ( `form_code` , `attribute_id` ) VALUES ( 'adminhtml_customer', '$attributeId' ), ( 'customer_account_create', '$attributeId' ), ( 'customer_account_edit', '$attributeId' )"; $write->query($query); } }