【问题标题】:How to add new custom field in Customer ‘Account page and in admin area?如何在客户的“帐户”页面和管理区域中添加新的自定义字段?
【发布时间】:2012-01-13 05:35:31
【问题描述】:

我知道这可能以前可能被问过,但是通过整个网络,我无法得到一个正确的工作帖子来解决我的问题。于是想到自己去问。

我想为我的客户的帐户和编辑页面创建一个自定义字段“公司”。我还想在“管理客户”部分的管理区域中查看此字段以及 ID、姓名、电子邮件、组、电话、国家/地区等其他字段。

我知道最好的办法是创建一个自定义模块,但这样做的确切方法是什么,以便新创建的模块在前端(A/c 注册和编辑页面)和后端(管理员) 区域。

如果有人能告诉我这样做的确切方法,我将不胜感激。

提前致谢。

【问题讨论】:

  • 公司字段包含在地址集合中

标签: php magento e-commerce custom-attributes


【解决方案1】:

我已经找到了解决方案。它的这个文件需要编辑以便在管理客户网格中添加一个额外的列。

app/code/core/Mage/AdminHtml/Block/Customers/Grid.php

    protected function _prepareCollection()
    {
       $collection = Mage::getResourceModel(‘customer/customer_collection’)
       // …
      // ADD THIS TO THE END:
      ->joinAttribute(
      ‘billing_company’, ‘customer_address/company’, ‘default_billing’, null, ‘left’);
      // …
    }

到列:

protected function _prepareColumns()
    {
       $this->addColumn(‘company’, array(
       ‘header’ => Mage::helper(‘customer’)->__(‘Company’),
       ‘index’ => ‘billing_company’));
        ...
    }

如果需要在客户注册和编辑页面上添加公司字段,那么他们需要编辑 customer/form/register.phtml 和 edit.phtml 文件并添加

      <label for="company"><?php echo $this->__('Company') ?></label>
                    <div class="input-box">
                        <input type="text" name="company" id="company"       value="<?php echo $this->htmlEscape($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" />
                    </div>

就是这样!!希望对大家有所帮助!

【讨论】:

  • 那么有谁知道我们是否想通过创建自定义模块来做完全相同的事情,我们该怎么做?我确实设法通过创建一个自定义模块来显示 d 列,因为我的“添加新客户”按钮关闭了。该列的值也没有显示?有什么建议吗?
猜你喜欢
  • 2019-12-12
  • 2021-05-30
  • 1970-01-01
  • 1970-01-01
  • 2018-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多