Create a small module by following the steps:
app/code/local/Sushant/CustomAttribute/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Sushant_CustomAttribute>
      <version>0.1.0</version>
    </Sushant_CustomAttribute>
  </modules>
  <global>
    <helpers>
      <customattribute>
        <class>Sushant_CustomAttribute_Helper</class>
      </customattribute>
    </helpers>
	<models>
	  <customattribute>
		<class>Sushant_CustomAttribute_Model</class>
		<resourceModel>customattribute_mysql4</resourceModel>
	  </customattribute>
	</models>
	<resources>
	  <customerattribute1434371772_setup>
		<setup>
		  <module>Sushant_CustomAttribute</module>
		  <class>Mage_Customer_Model_Entity_Setup</class>
		</setup>
		<connection>
		  <use>core_setup</use>
		</connection>
	  </customerattribute1434371772_setup>
	  <customerattribute1434371772_write>
		<connection>
		  <use>core_write</use>
		</connection>
	  </customerattribute1434371772_write>
	  <customerattribute1434371772_read>
		<connection>
		  <use>core_read</use>
		</connection>
	  </customerattribute1434371772_read>
	</resources>
  </global>
</config>

app/code/local/Sushant/CustomAttribute/Helper/Data.php

<?php
class Sushant_CustomAttribute_Helper_Data extends Mage_Core_Helper_Abstract
{
}
?>

app/code/local/Sushant/CustomAttribute/sql/customerattribute1434371772_setup/mysql4-install-0.1.0.php

<?php
$installer = $this;
$installer->startSetup();

$installer->addAttribute("customer", "job",  array(
    "type"     => "varchar",
    "backend"  => "",
    "label"    => "Job",
    "input"    => "text",
    "source"   => "",
    "visible"  => true,
    "required" => true,
    "default" => "",
    "frontend" => "",
    "unique"     => false,
    "note"       => ""

	));

        $attribute   = Mage::getSingleton("eav/config")->getAttribute("customer", "job");

$used_in_forms=array();

$used_in_forms[]="adminhtml_customer";
$used_in_forms[]="checkout_register";
$used_in_forms[]="customer_account_create";
$used_in_forms[]="customer_account_edit";
$used_in_forms[]="adminhtml_checkout";
        $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", 1)
		->setData("sort_order", 100)
		;
        $attribute->save();

$installer->endSetup();

app/etc/modules/Sushant_CustomAttribute.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Sushant_CustomAttribute>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </Sushant_CustomAttribute>
  </modules>
</config>

Modify located file at:

app/design/frontend/rwd/default/template/persistent/customer/formregister.phtml

and add:

<div class="input-box">
    <label for="YourAttributeName"><?php echo $this->__('Job') ?><span class="required">*</span></label><br />
    <input type="text" name="job" id="job" value="<?php echo $this->htmlEscape($this->getFormData()->getYourAttributeName()) ?>" title="<?php echo $this->__('job') ?>" class="required-entry input-text" />
</div>

If you want customer to be able to modify the attribute in customer panel, then modify:

app/design/frontend/rwd/default/template/customer/form/edit.phtm

and add:

<li>
    <label for="Job" class="required"><em>*</em><?php echo $this->__('Job') ?></label>
    <div class="input-box">
        <input type="text" name="job" id="job" value="<?php echo $this->escapeHtml($this->getCustomer()->getJob()) ?>" title="<?php echo $this->__('Job') ?>" class="input-text required-entry" />
    </div>
</li>


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *