AbanteCart Community

Shopping Cart Operations => Support => Topic started by: Augustin on August 12, 2018, 04:56:31 PM

Title: How to add a new column to product grid?
Post by: Augustin on August 12, 2018, 04:56:31 PM
Hi Guys!
How can I add a new column to the grid of products, please?
I need to have the product id showing in the grid, as well.
There is an older post from 2013 [http://forum.abantecart.com/index.php/topic,1433.msg5585.html#msg5585] with the same question, but without a solution  :'(
Thank you very much!
Title: Re: How to add a new column to product grid?
Post by: abolabo on August 13, 2018, 04:02:12 AM
Grid consist of three controllers.
1. Page controller in your case pages/catalog/product.php
2. common/listing_grid.php - common controller that builds grid wrapper html.
3. Response controller that  returns row cells for grid by ajax.

To add column you should to  add  column into grid definition and add column into response.
1. you can change grid definitions with hook
Code: [Select]
public function onControllerCommonListingGrid_InitData(){
$that =& $this->baseObject;
$that->loadLanguage('reward_points/reward_points');
$data = &$that->data;
if($data['table_id'] == 'product_grid'){

//your code here
$data['colNames'][] = 'your column name';
$data['colModel'] = array(
            array(
                'name'     => '****',
                'index'    => '****',
                'align'    => 'center',
                'width'    => 65,
                'sortable' => false,
                'search'   => false,
            );
                }
}

2. then change response

Code: [Select]
public function onControllerResponsesListingGridProduct_UpdateData()
{
$that =& $this->baseObject;
$response =& $that->data['response'];
foreach($response->rows as &$row){
      $row['cell'][] = 'ffffff';
}

}
Title: Re: How to add a new column to product grid?
Post by: Augustin on August 13, 2018, 07:08:55 PM
Thank you very much, Abolabo!