Opencart 2将自定义客户数据添加到管理客户配置文件页面

时间:2016-03-16 15:38:57

标签: php mysql opencart2.x

我有一个新的mysql表我称之为co_customer,它存储有关客户的其他独特内容。这些内容我都可以查看并在客户注册表上工作。但是,我现在正尝试在管理面板客户资料页面上编辑这些新的自定义字段。 我目前正在测试这个,以获得一个新的领域。但是新字段是空白的,我在页面顶部收到以下错误

Notice: Undefined index: cofirstname in  
/home/public_html/admin/controller/customer/customer.php on line 972

我编辑了以下文件 的public_html /管理/模型/客户/ customer.php

public function getCustomer($customer_id) 
 {
     $query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "'");
     return $query->row;

             //get coapplicant data
             $cocustomersql = $this->db->query("SELECT * FROM " . DB_PREFIX . "co_customer WHERE customer_id = '" . (int)$customer_id . "'");
             if ($cocustomersql->num_rows > 0) 
             {
                  return $cocustomersql->row;
             }
 }

我编辑了以下文件 的public_html /后台/控制器/客户/ customer.php

 if (isset($this->request->post['cofirstname'])) 
    {
        $data['cofirstname'] = $this->request->post['cofirstname'];
    } elseif (!empty($customer_info)) {
        $data['cofirstname'] = $customer_info['cofirstname'];
    } else {
        $data['cofirstname'] = '';
    }

1 个答案:

答案 0 :(得分:1)

我建议使用OpenCart的现有功能,而不是编辑代码。

登录Admin/Customers/Custom Fields,您可以在此处添加字段并将其分配给客户

enter image description here

for detail