dongpai2468 2015-02-07 10:49
浏览 44
已采纳

Prestashop - 显示供应商名称而不是ID

In the list view, i would like show supplier names instead the id. The view is generated automatically. How can I change it?

The code i have in the renderList option is:

public function renderList()
{
    $this->addRowAction('view');
    // Adds an Edit button for each result
    $this->addRowAction('edit');

    // Adds a Delete button for each result
    $this->addRowAction('delete');

    $this->simple_header = false;

    return parent::renderList();
}

and the field list is the next one:

$this->fields_list = array(
        ...
        'id_product_supplier' => array('title' => $this->l('ID Supplier'), 'align' => 'center', 'class' => 'fixed-width-xs'),
        ...
        );

If i want show the name of the supplier instead the Id, and have the option to filter for suppliers in the list...

What can i do?

Thanks!

  • 写回答

1条回答 默认 最新

  • doushi5752 2015-02-07 18:17
    关注

    You can change it in two ways, depending on whose controller is it (yours of default):

    If you built your own admin controller:

    public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
    {
        parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
    
        foreach($this->_list as &row)
        {
            $row['new_field'] = 'Hello';
            $row['existing_field'] = 'Changed';
        }
    }
    

    If you're using a module to modify and existing form:

    public function hookActionAdminProductsListingResultsModifier($args)
    {
        $args['list_total'] += 1;
    
        foreach($args['list'] as &row)
            {
            $row['new_field'] = 'Hello';
                $row['existing_field'] = 'Changed';
        }
    }
    

    If you are goona use a hook, you must register is first. Also, cange the {AdminProducts} part in the hook name.

    For more info, see classes/controller/AdminController.php @ Line 2952.

    Hook::exec('action'.$this->controller_name.'ListingResultsModifier', array(
        'list' => &$this->_list,
        'list_total' => &$this->_listTotal,
    ));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 写uniapp时遇到的问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流