I have done this with the following steps.
Suppose if you want to add "occupation" after email
Open template/customer/form/register.phtml and template/customer/form/edit.phtml
<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>
Now open app\code\core\Mage\Customer\etc\config.xml
and add <occupation><create>1</create><update>1</update></occupation>
after <fieldsets><customer_dataflow>
Now open app\code\core\Mage\Customer\Model\Resource\Setup.php
find $entities = array( and add the following code
'occupation' => array(
'type' => 'varchar',
'label' => 'Fax',
'input' => 'text',
'required' => false,
'sort_order' => 130,
'validate_rules' => 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}',
'position' => 130,
),
Now i insert some value in db
- See more at: http://www.excellencemagentoblog.com/customer-registration-fields-magento1-6#sthash.ubBrtvuS.dpuf
- See more at: http://www.excellencemagentoblog.com/customer-registration-fields-magento1-6#sthash.ubBrtvuS.dpuf
INSERT INTO `eav_attribute` (
`attribute_id` ,
`entity_type_id` ,
`attribute_code` ,
`attribute_model` ,
`backend_model` ,
`backend_type` ,
`backend_table` ,
`frontend_model` ,
`frontend_input` ,
`frontend_label` ,
`frontend_class` ,
`source_model` ,
`is_required` ,
`is_user_defined` ,
`default_value` ,
`is_unique` ,
`note`
)
VALUES (
NULL , '1', 'occupation', NULL , NULL , 'int', NULL , NULL , 'select', 'School', NULL , 'profile/entity_school', '1', '0', '0', '0', ''
);
INSERT INTO `eav_entity_attribute` (
`entity_attribute_id` ,
`entity_type_id` ,
`attribute_set_id` ,
`attribute_group_id` ,
`attribute_id` ,
`sort_order`
)
VALUES (
NULL , '1', '1', '1', '121', '0'
);
INSERT INTO `customer_eav_attribute` (
`attribute_id` ,
`is_visible` ,
`input_filter` ,
`multiline_count` ,
`validate_rules` ,
`is_system` ,
`sort_order` ,
`data_model`
)
VALUES (
'121', '1', NULL , '1', NULL , '0', '0', NULL
);
INSERT INTO `customer_eav_attribute_website` (
`attribute_id` ,
`website_id` ,
`is_visible` ,
`is_required` ,
`default_value` ,
`multiline_count`
)
VALUES (
'121', '0', '1', '0', NULL , NULL
);
INSERT INTO `customer_form_attribute` (
`form_code` ,
`attribute_id`
)
VALUES (
'adminhtml_customer', '121'
), (
'checkout_register', '121'
), (
'customer_account_create', '121'
), (
'customer_account_edit', '121'
)
;
Also go to the
System→Configurations→Customers→Customer Configurations→Address Templates
and Add this code in the “Text” textarea:-
Add this code in the “Html” textarea
Suppose if you want to add "occupation" after email
Open template/customer/form/register.phtml and template/customer/form/edit.phtml
<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>
Now open app\code\core\Mage\Customer\etc\config.xml
and add <occupation><create>1</create><update>1</update></occupation>
after <fieldsets><customer_dataflow>
Now open app\code\core\Mage\Customer\Model\Resource\Setup.php
find $entities = array( and add the following code
'occupation' => array(
'type' => 'varchar',
'label' => 'Fax',
'input' => 'text',
'required' => false,
'sort_order' => 130,
'validate_rules' => 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}',
'position' => 130,
),
Now i insert some value in db
INSERT
INTO
`eav_attribute` (
`attribute_id` ,
`entity_type_id` ,
`attribute_code` ,
`attribute_model` ,
`backend_model` ,
`backend_type` ,
`backend_table` ,
`frontend_model` ,
`frontend_input` ,
`frontend_label` ,
`frontend_class` ,
`source_model` ,
`is_required` ,
`is_user_defined` ,
`default_value` ,
`is_unique` ,
`note`
)
VALUES
(
NULL
,
'1'
,
'school'
,
NULL
,
NULL
,
'int'
,
NULL
,
NULL
,
'select'
,
'School'
,
NULL
,
'profile/entity_school'
,
'1'
,
'0'
,
'0'
,
'0'
,
''
);
INSERT
INTO
`eav_attribute` (
`attribute_id` ,
`entity_type_id` ,
`attribute_code` ,
`attribute_model` ,
`backend_model` ,
`backend_type` ,
`backend_table` ,
`frontend_model` ,
`frontend_input` ,
`frontend_label` ,
`frontend_class` ,
`source_model` ,
`is_required` ,
`is_user_defined` ,
`default_value` ,
`is_unique` ,
`note`
)
VALUES
(
NULL
,
'1'
,
'school'
,
NULL
,
NULL
,
'int'
,
NULL
,
NULL
,
'select'
,
'School'
,
NULL
,
'profile/entity_school'
,
'1'
,
'0'
,
'0'
,
'0'
,
''
);
`attribute_id` ,
`entity_type_id` ,
`attribute_code` ,
`attribute_model` ,
`backend_model` ,
`backend_type` ,
`backend_table` ,
`frontend_model` ,
`frontend_input` ,
`frontend_label` ,
`frontend_class` ,
`source_model` ,
`is_required` ,
`is_user_defined` ,
`default_value` ,
`is_unique` ,
`note`
)
VALUES (
NULL , '1', 'occupation', NULL , NULL , 'int', NULL , NULL , 'select', 'School', NULL , 'profile/entity_school', '1', '0', '0', '0', ''
);
INSERT INTO `eav_entity_attribute` (
`entity_attribute_id` ,
`entity_type_id` ,
`attribute_set_id` ,
`attribute_group_id` ,
`attribute_id` ,
`sort_order`
)
VALUES (
NULL , '1', '1', '1', '121', '0'
);
INSERT INTO `customer_eav_attribute` (
`attribute_id` ,
`is_visible` ,
`input_filter` ,
`multiline_count` ,
`validate_rules` ,
`is_system` ,
`sort_order` ,
`data_model`
)
VALUES (
'121', '1', NULL , '1', NULL , '0', '0', NULL
);
INSERT INTO `customer_eav_attribute_website` (
`attribute_id` ,
`website_id` ,
`is_visible` ,
`is_required` ,
`default_value` ,
`multiline_count`
)
VALUES (
'121', '0', '1', '0', NULL , NULL
);
INSERT INTO `customer_form_attribute` (
`form_code` ,
`attribute_id`
)
VALUES (
'adminhtml_customer', '121'
), (
'checkout_register', '121'
), (
'customer_account_create', '121'
), (
'customer_account_edit', '121'
)
;
Also go to the
System→Configurations→Customers→Customer Configurations→Address Templates
and Add this code in the “Text” textarea:-
{{depend occupation}}{{var occupation}}{{/depend}}
Add this code in the “Html” textarea
{{depend occupation}}{{var occupation}}<br />{{/depend}}
Add the below code in the “PDF” text area.
{{depend occupation}}{{var occupation}}|{{/depend}}
Tried this, but doesn't seem to be saving the entered info.
ReplyDeletehttp://fitnessp.nextmp.net/
I had to make a couple changes:
-getFormData changed to getCustomer
-htmlEscape changed to escapeHtml
Both changes consistent with existing "email" input.
I also wonder if the $entities array "label" should be "Occupation" not "Fax".
I double-checked the SQL, all rows were added.
With my changes, the field show up properly.
I can enter info, but it does not appear later.
Do I have to somehow run the "setup.php" file?
p.s. yes I am a total Magento noob.
Hi, can it is working for any other user.. becoz for me it is not working fine..
ReplyDeletePlease help me out
I have done every thing you said here, modify the config.xml, register.phtml, Setup.php and the Adress Template.... I can see the new fields on the register form and on the db, but i can't see the data....
ReplyDeleteWhat else can i do????, thanks!!
above code it not working..
ReplyDelete