Jump to content

petermein

Members
  • Posts

    3
  • Joined

  • Last visited

Profile Information

  • Location
    Groningen
  • Activity
    Developer

petermein's Achievements

Newbie

Newbie (1/14)

2

Reputation

  1. Ok i let go of adding a column to the product controller and moved to the AdminOrdersControllers. Here there is a call back functionality on the list_fields and it works like a charm. For anyone interested here is my code with a little explaination: <?php class AdminOrdersController extends AdminOrdersControllerCore { public function __construct(){ parent::__construct(); /* override the existing select query */ $this->_select = ' a.id_currency, a.id_order AS id_pdf, a.id_order AS id_test, /* Added to have the field name available */ CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->fields_list['id_test'] = array( 'title' => $this->l('test'), 'width' => 35, 'align' => 'center', 'callback' => 'testCallback', /* define callback function to get a value for this field */ 'orderby' => false, 'search' => false, 'remove_onclick' => true); } public function testCallback($id_test, $tr){ /* Get information from database that you want to be displayed */ $sql = "SELECT state FROM ". _DB_PREFIX_ ."test WHERE order_id = ". $id_test .""; $row = Db::getInstance()->getRow($sql); /* Assign some smarty variables */ $this->context->smarty->assign(array( 'test' => $row['variable'] )); /* Because youre overriding an AdminController youre in a rather wierd path so i hard coded my smarty template in a string */ $tpl = '<span style="width:20px; margin-right:5px;"> {if ($test== 1)} <img src="../img/exact/1.png" alt="success" /> {elseif ($test= 0)} <img src="../img/exact/2.png" alt="failed" /> {else} <img src="../img/exact/3.png" alt="todo" /> {/if} </span>'; /* Fetch the string with the resource prefix string: */ return $this->context->smarty->fetch('string:'. $tpl); } } Good luck with the code if you can use it.
  2. Thanks, But the problem is that the parent of getList ( AdminController::getList ) builds a query to get the data from the product table. '.($this->_tmpTableFilter ? ' * FROM (SELECT ' : ''); if ($this->explicitSelect) { foreach ($this->fields_list as $key => $array_value) { // Add it only if it is not already in $this->_select if (isset($this->_select) && preg_match('/[\s]`?'.preg_quote($key, '/').'`?\s*,/', $this->_select)) continue; if (isset($array_value['filter_key'])) $this->_listsql .= str_replace('!', '.', $array_value['filter_key']).' as '.$key.','; elseif ($key == 'id_'.$this->table) $this->_listsql .= 'a.`'.bqSQL($key).'`,'; elseif ($key != 'image' && !preg_match('/'.preg_quote($key, '/').'/i', $this->_select)) $this->_listsql .= '`'.bqSQL($key).'`,'; } $this->_listsql = rtrim($this->_listsql, ','); } else $this->_listsql .= ($this->lang ? 'b.*,' : '').' a.*'; Ofcourse i can edit this part to exclude my variable but i dont like doing core upgrades for 1 module.
  3. Hi there, Im trying to create an override for AdminProductsController from my module. The overide works perfectly but i want to create an extra column the table. class AdminProductsController extends AdminProductsControllerCore { public function __construct() { $this->fields_list['Test'] = array( 'title' => 'Test', 'align' => 'left', 'width' => 80 ); parent::__construct(); } } The above code does the job of adding a new column, however instead of getting the data from the product table itself. I want to define a function or a fixed value to this column. Does anyone know if this is possible ?
×
×
  • Create New...