Jump to content

logic behind product list


longy

Recommended Posts

I'm trying from a module to interact with products list in bo. I can add custom columns but i can't filter/interact/order them.

To add custom columns i just need to override AdminProductController in this way:

 

parent::__construct();

$this->_select .= ", (date_upd - date_add) as talu ";

 

$this->fields_list['talu'] = array(

'title' => 'An Amazing Field',

'width' => 70,

'align' => 'center',

'type' => 'bool'

);

 

But i don't know how to apply filter or order by this column.

Link to comment
Share on other sites

im affraid that it's not possible to order list with combined field,

in fact, this field doesnt exist in database table, so it can be problematic

 

anyway, you can try to add there filter_key value

'filter_key' => 'talu'

Link to comment
Share on other sites

AdminProductController extends AdminController that has _where and _orderBy properties, i don't remember if they are protected or public however my class has also these properties. So i could do something like:

 

parent::__construct();

$this->_where .= "and (date_upd - date_add) = $something";
 

And something similar also for $this->_orderBy.

 

However if I active "filter" and "order" in fields_list array for key 'talu', 'talu' attribute is appended to query and generate sql exception because 'talu' isn't a real field.

 

Maybe I can solve removing unwanted parts of the query using str_replace but I've to find the right method to override, because these parts aren't appended in AdminController constructor .

 

I would also know how to customize visualization for custom fields in order to allow interaction (something similar to enable/disable button for product status).

Edited by longy (see edit history)
Link to comment
Share on other sites

AdminProductController extends AdminController that has _where and _orderBy properties, i don't remember if they are protected or public however my class has also these properties. So i could do something like:

 

parent::__construct();

$this->_where .= "and (date_upd - date_add) = $something";

 

And something similar also for $this->_orderBy.

 

However if I active "filter" and "order" in fields_list array for key 'talu', 'talu' attribute is appended to query and generate sql exception because 'talu' isn't a real field.

 

Maybe I can solve removing unwanted parts of the query using str_replace but I've to find the right method to override, because these parts aren't appended in AdminController constructor .

 

I would also know how to customize visualization for custom fields in order to allow interaction (something similar to enable/disable button for product status).

 

I had the same problem and yes, if you remove the unwanted part of query it works...I would know the answer of your second question...

Edited by logan871 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...