Home » Magento, Solved Issues, php

add new fields to customer registration and admin manage customer

21 April 2012 No Comment

Go through below code and rub sql queries that need to get executed.

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′, ‘karat10′, NULL , NULL , ‘varchar’, NULL , NULL , ‘text’, ‘Karat 10 ‘, NULL , ”, ‘1′, ‘0′, ‘0′, ‘0′, ”
);

After insert query, the attribute generated is my case is 154. Next this attribute needs to be associated to an attribute set, the sql for this is

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′, ‘154′, ‘2′
);

INSERT INTO `customer_eav_attribute` (
`attribute_id` ,
`is_visible` ,
`input_filter` ,
`multiline_count` ,
`validate_rules` ,
`is_system` ,
`sort_order` ,
`data_model`
)
VALUES (
‘154′, ‘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 (
‘154′, ‘0′, ‘1′, ‘0′, NULL , NULL
);

INSERT INTO `customer_form_attribute` (
`form_code` ,
`attribute_id`
)
VALUES (
‘adminhtml_customer’, ‘154′
), (
‘checkout_register’, ‘154′
), (
‘customer_account_create’, ‘154′
), (
‘customer_account_edit’, ‘154′
)
;

now you can see newly added field in admin manage customer section.

now to add this in registration page add blow code in your registration.phtml where ever you want to display it.

………………..

  • $attribute = Mage::getModel('eav/config')->getAttribute(‘customer’,'Karat 10′);
    ?>