我正在运行 prestashop 1.4.8.3 并且我在 AdminCustomers.php 上尝试了以下修改
$this->_select = '(YEAR(CURRENT_DATE)-YEAR(`birthday`)) - (RIGHT(CURRENT_DATE, 5)<RIGHT(`birthday`, 5)) as age, (
SELECT c.date_add FROM ' . _DB_PREFIX_ . 'guest g
LEFT JOIN ' . _DB_PREFIX_ . 'connections c ON c.id_guest = g.id_guest
WHERE g.id_customer = a.id_customer
ORDER BY c.date_add DESC
LIMIT 1
) as connect';
// This is new code
$this->_select = '(SELECT d.company FROM ' . _DB_PREFIX_ . 'address d WHERE d.id_customer = a.id_customer LIMIT 1) as company';
// LH company name
$genders = array(
1 => $this->l('M'),
2 => $this->l('F'),
9 => $this->l('?'));
$this->fieldsDisplay = array(
'id_customer' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 25),
'id_gender' => array(
'title' => $this->l('Gender'),
'width' => 25,
'align' => 'center',
'icon' => array(
1 => 'male.gif',
2 => 'female.gif',
'default' => 'unknown.gif'),
'orderby' => false,
'type' => 'select',
'select' => $genders,
'filter_key' => 'a!id_gender'),
'lastname' => array('title' => $this->l('Last Name'), 'width' => 80),
'firstname' => array('title' => $this->l('First name'), 'width' => 60),
'email' => array(
'title' => $this->l('E-mail address'),
'width' => 120,
'maxlength' => 19),
'company' => array('title' => $this->l('Company'), 'width' => 60),
'age' => array(
'title' => $this->l('Age'),
'width' => 30,
'search' => false),
'active' => array(
'title' => $this->l('Enabled'),
'width' => 25,
'align' => 'center',
'active' => 'status',
'type' => 'bool',
'orderby' => false),
'newsletter' => array(
'title' => $this->l('News.'),
'width' => 25,
'align' => 'center',
'type' => 'bool',
'callback' => 'printNewsIcon',
'orderby' => false),
'optin' => array(
'title' => $this->l('Opt.'),
'width' => 25,
'align' => 'center',
'type' => 'bool',
'callback' => 'printOptinIcon',
'orderby' => false),
'date_add' => array(
'title' => $this->l('Registration'),
'width' => 30,
'type' => 'date',
'align' => 'right'),
'connect' => array(
'title' => $this->l('Connection'),
'width' => 60,
'type' => 'datetime',
'search' => false));
奇怪的是,它似乎可以工作,但只有一两次浏览器刷新,然后它无法显示 SQL 失败消息。
任何能让我走上正轨的想法都将受到高度赞赏。