0

我想向注册页面添加一个新的自定义字段。第 1 步我像这样更改配置 xml (app\code\core\Mage\Customer\etc\config.xml)。

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

</customer_account>

第 2 步将字段添加到 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>

步骤 3 使用此查询将新属性插入数据库。

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,'');

我的问题是如何在客户帐户编辑页面中查看公司名称。如果有人在这方面帮助我,非常感谢。谢谢

4

1 回答 1

0

我找到了添加自定义额外字段的方法。

以下是添加额外字段的步骤。

  1. 我像这样更改配置 xml (app\code\core\Mage\Customer\etc\config.xml)。

    <customer_account>
        <businessregistration>
            <create>1</create>
            <update>1</update>
            <name>1</name>
            </companyname>
       </businessregistration>
    
  2. 将该字段添加到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. 将这些查询添加到数据库表中:

    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 是上述查询中最后插入的 id。

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

现在新添加的“商业登记”对我来说很好用。

干杯。

于 2013-10-14T10:13:57.150 回答