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

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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?