我刚在表客户中创建了一行。我有一个在那里写信息的模块。它工作正常,但我无法在模板中显示此字段,这是我更改的内容: 目录/模型/帐户/ 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
获得答案 0 :(得分:0)
您必须编辑核心文件system/library/customer.php
并在登录时将此字段添加到SELECT
部分,然后创建新的 getter 方法以检索此属性。
E.g:
private $competition_rate;
private $address_id;
$this->address_id = $customer_query->row['competition_rate'];
$this->address_id = $customer_query->row['address_id'];
public function getCompetitionRate() { return $this->competition_rate; }
现在,您可以在标题中调用$this->customer->getCompetitionRate()
方法。