Domanda

i want to add a new custom field to registration page. step 1 i change the config xml (app\code\core\Mage\Customer\etc\config.xml) like this.

<customer_account>
  <companyname>
    <create>1</create>
    <update>1</update>
    <name>1</name>
  </companyname>

</customer_account>

step 2 add the field to registration.phtml (app\design\frontend\template\customer\form\registration.phtml)

<div class="field">
                    <label for="password" class="required"><em>*</em><?php echo $this->__('Business Name') ?></label>
                    <div class="input-box">
                        <input type="text" name="companyname" id="companyname" title="<?php echo $this->__('companyname') ?>" class="input-text required-entry" />
                    </div>
</div>

step 3 insert the new attribute to database using this query.

insert into `eav_attribute` (`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(1, 'companyname', '', '', 'varchar', '', '', 'text', 'Company Name', '', '', 1, 0, '', 0,'');

my question is how to view the company name in customer account edit page. great thank you if any one help me on this. thanks

È stato utile?

Soluzione

I found the way to add customise extra field.

Following are the steps for adding an extra field.

  1. I change the config xml (app\code\core\Mage\Customer\etc\config.xml) like this.

    <customer_account>
        <businessregistration>
            <create>1</create>
            <update>1</update>
            <name>1</name>
            </companyname>
       </businessregistration>
    
  2. Add the field to registration.phtml (app\design\frontend\template\customer\form\registration.phtml)

    <div class="field">
        <label for="businessregistration" class="required"><em>*</em><?php echo $this->__('Buisiness Registration') ?></label>
        <div class="input-box">
            <input type="text" name="businessregistration" id="businessregistration" title="<?php echo $this->__('businessregistration') ?>" class="input-text required-entry" />
        </div>
    </div>
    
  3. Add these queries to the database tables:

    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', 'buisinessregistration', NULL, NULL, 'text', NULL, NULL, 'text', 'Business Registration', NULL, NULL, '0', '0', NULL, '0', NULL);
    

965 is the last inserted id from above query.

Insert into `eav_entity_attribute` 
set entity_type_id = 1,
    attribute_set_id = 1,
    attribute_group_id = 1,
    attribute_id = 965,
    sort_order = 111

insert into `customer_eav_attribute` 
set attribute_id = "965",
    is_visible = 1,
    multiline_count = 1,
    is_system = 0,
    sort_order = 111

insert into `customer_form_attribute` 
set form_code = "adminhtml_customer",
    attribute_id = 965

insert into `customer_form_attribute` 
set form_code = "checkout_register", attribute_id = 965 

insert into `customer_form_attribute` 
set form_code = "customer_account_create", attribute_id = 965

insert into `customer_form_attribute` 
set form_code = "customer_account_edit", attribute_id = 965

Now the newly added "Business Registration" works fine for me.

Cheers.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top