opencart将extrafield添加到帐户

时间:2014-02-20 11:24:29

标签: php mysql opencart

我刚在表客户中创建了一行。我有一个在那里写信息的模块。它工作正常,但我无法在模板中显示此字段,这是我更改的内容: 目录/模型/帐户/ customer.php

$sql = "SELECT *, CONCAT(c.firstname, ' ', c.lastname,' ',c.competition_rate,c) AS name, cg.name AS customer_group FROM " . DB_PREFIX . "customer c LEFT JOIN " . DB_PREFIX . "customer_group cg ON (c.customer_group_id = cg.customer_group_id) ";

目录/视图/模板/默认/ ommon / header.php文件

<?php echo $competition_rate; ?>

目录/控制器/通用/ header.php文件

$this->data['text_logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/account', '', 'SSL'), $this->customer->getFirstName(),$this->customer->getcompetition_rate(), $this->url->link('account/logout', '', 'SSL'));

我得到以下

  

致命错误:在第76行的C:\ xampp \ htdocs \ sport \ catalog \ controller \ common \ header.php中调用未定义的方法Customer :: getcompetition_rate()

我错过了什么?请帮忙!这一行的信息可以通过PhpMyadmin

获得

1 个答案:

答案 0 :(得分:0)

您必须编辑核心文件system/library/customer.php并在登录时将此字段添加到SELECT部分,然后创建新的 getter 方法以检索此属性。

E.g:

  1. private $competition_rate;
  2. 之后添加private $address_id;
  3. $this->address_id = $customer_query->row['competition_rate'];
  4. 之后添加$this->address_id = $customer_query->row['address_id'];
  5. 创建新方法public function getCompetitionRate() { return $this->competition_rate; }
  6. 现在,您可以在标题中调用$this->customer->getCompetitionRate()方法。