Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: How to add a new column to product grid?  (Read 3029 times)

Offline Augustin

  • Newbie
  • *
  • Posts: 5
  • Karma: +1/-0
    • View Profile
How to add a new column to product grid?
« 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!

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: How to add a new column to product grid?
« Reply #1 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';
}

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

Offline Augustin

  • Newbie
  • *
  • Posts: 5
  • Karma: +1/-0
    • View Profile
Re: How to add a new column to product grid?
« Reply #2 on: August 13, 2018, 07:08:55 PM »
Thank you very much, Abolabo!

 

Powered by SMFPacks Social Login Mod