douhuan3448 2012-10-09 07:52
浏览 23

将公司字段添加到BackOffice中的“客户”选项卡

I'm running prestashop 1.4.8.3 and I've tried the following modification on 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));

The weird thing is that it seems to work, but only for one or two browser refreshes, afterward it fails displaying an SQL fail message.

Any idea that would put me on the right track would be highly appreciated.

  • 写回答

2条回答 默认 最新

  • dongziche8030 2012-10-09 11:08
    关注

    You may try it:

    // 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';
    

    Also you may see your sql-query here: AdminTab::getList() on line $this->_list = Db::getInstance()->ExecuteS($sql);

    评论

报告相同问题?