News:

AbanteCart v1.4.2 is released.

Main Menu

How to add a new column to product grid?

Started by Augustin, August 12, 2018, 04:56:31 PM

Previous topic - Next topic

Augustin

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!

abolabo

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
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

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

}
"No one is useless in this world who lightens the burdens of another."
― Charles Dickens

Augustin


Forum Rules Code of conduct
AbanteCart.com 2010 -