Step I Add a occupation/title field to the user registration page, almost 54 lines in register.html, add a occupation display code below the email
-
Code:
-
<li>
<div class= "Input-box";
<label for= "email_address" ; <?php echo $this->__ (' Email Address ')?> <span class= "required" >*</span></label><br/
<input type= "text" name= "email" id= "email_address" value= "<?php Echo $this->htmlescape ($this Getformdata ()->getemail ())?> "title=" <?php Echo $this->__ (' Email Address ')?> "class=" Validate-email Required-entry input-text "/>
</div>
<div class=" Input-box ";
<label for=" occupation " ><?php echo $this->__ (' Occupation/title ')? ></label><br/>
<input type= "text" Name= " Occupation "id=" occupation "value=" <?php Echo $this->htmlescape ($this->getformdata ()->getoccupation ()) ?> "title=" <?php Echo $this->__ (' occupation ')?> "class=" Input-text "/>
</div>
</li
This is, if you go to the User registration page, you will see the new fields.
Step 2 Also in edit.phtml, add occupation display block
-
Code:
-
<li>
<div class= "Input-box";
<label for= "email" ><?php ech o $this->__ (' Email Address ')?> <span class= "required" >*</span></label><br/>
< Input type= "text" name= "email" id= "email" value= "<?php Echo $this->htmlescape ($this->getcustomer () Getemail ())?> "title=" <?php Echo $this->__ (' Email Address ')?> "class=" Required-entry validate-email Input-text "/>
</div>
</li>
<li>
<div class=" Input-box ";
<label for= "Occupation" ><?php Echo $this->__ (' occupation ')?> </label><br/>
<input type= "text" Name= "Occupation" id= "occupation" value= "<?php Echo $this->htmlescape ($this->getcustomer () Getoccupation ())?> "title=" <?php Echo $this->__ (' occupation ')?> "class=" Input-text "/>
</div
</li>
Step 3, open model/entity/setup.php almost 93 lines, below the email, add the relevant code of Occupation:
-
Code:
-
‘email‘ => array(
‘type‘ => ‘static‘,
‘label‘ => ‘Email‘,
‘class‘ => ‘validate-email‘,
‘sort_order‘ => 60,
),
‘occupation‘ => array(
‘label‘ => ‘Occupation‘,
‘required‘ => false,
‘sort_order‘ => 65,
),
Step 4: Now the code is basically written, but we still need to perform a database operation to add the occupation attribute to the Eav_attribute table, putting the following block of code:
-
Code:
-
<?php
$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup‘);
$AttrCode = ‘occupation‘;
$settings = array (
‘position‘ => 1,
‘is_required‘=> 0
);
$setup->addAttribute(‘1‘, $AttrCode, $settings);
?>
Put it in the appropriate file and execute it once. I recommend putting it at the top of the register.html file and then revisit register.html. View the database Eav_attribute table to see the new entries. Then remove the above code from the register.phtml.
Step 5: Finally need to edit App/code/core/mage/customer/etc/config.xml's <fieldsets> tag to declare how the field handles insertions and expensive updates
-
Code:
-
<fieldsets>
<customer_account>
.....
<occupation><create>1</create><update>1</update></occupation>
</customer_account>
</fieldsets>
Magento Adding a field to the user registration (GO)