Schtev Posted October 22, 2013 Share Posted October 22, 2013 (edited) In the backoffice I want to add a column for product condition to the products list. I went to controllers/admin/AdminProductsController.php and added the following to the $this->field_list definition: $this->fields_list['condition'] = array( 'title' => $this->l('Condition'), 'align' => 'left' ); Much to my surprise, this resulted in the following error: Bad SQL queryColumn 'condition' in field list is ambiguous I went into the MySQL command line to see what's up. I typed the following query: SELECT condition FROM ps_product; This resulted in an incorrect syntax error. Puzzling! Further research revealed that "condition" is a reserved word in MySQL, so modifying the query like so solved the problem: SELECT `condition` FROM ps_product; Is this why my PHP code fails? Or am I missing something? Edited October 23, 2013 by vekia (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted October 23, 2013 Share Posted October 23, 2013 hello this field is ambigious because it also appears in other tables. what to do? in select clause you have to define different name for example p.condition as pcondition then in field definition instead of condition use pcondition Link to comment Share on other sites More sharing options...
Schtev Posted October 23, 2013 Author Share Posted October 23, 2013 Yup! That did it. Thank you. For the benefit of others, here's the solution: Select statement: $this->_select .= $alias.'.`condition` AS cond, '; Field statement: $this->fields_list['cond'] = array( 'title' => $this->l('Condition'), 'align' => 'left', 'width' => 80 ); Link to comment Share on other sites More sharing options...
vekia Posted October 23, 2013 Share Posted October 23, 2013 brilliant thank you for confirmation and for posting full solution im going to mark this thread as [solved] with regards, Milos Link to comment Share on other sites More sharing options...
divam Posted July 1, 2015 Share Posted July 1, 2015 (edited) am creating report module based on dispatched order and pending order my question is in SQL 1.How to add "where" clause ,2. How to find Deliver product order in presta shop table in db , 3. i was written where condition for current date and yesterday in controller its not working anybody pls suggest my queries . Edited July 1, 2015 by divam (see edit history) Link to comment Share on other sites More sharing options...
marcin_jaworski Posted June 29, 2016 Share Posted June 29, 2016 I have something like this: $this->_join .= ' LEFT JOIN (SELECT `name` as manufacturer,`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` ) AS manu ON (manu.`id_manufacturer` = a.`id_manufacturer`) '; Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now