Jump to content

Modify default SQL in Admin Orders


sini

Recommended Posts

Hi,

 

 I would like to change default SQL in Admin Orders like add NOT LIKE codition -> I want show all orders without orders from customer "P. Guest". So i try change line 75 in /controllers/admin/AdminOrderContoller.php like this:

 

LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.') WHERE 1 HAVING `customer` NOT LIKE '%P. Guest%'';

 

But it gives me error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE 1 ORDER BY a.`id_order` DESC LIMIT 0, 50' at line 21

 

Could you help me how to change default SQL?

 

Thank you in advance and sorry for my English

Link to comment
Share on other sites

The query is created dynamically according to the fields filled in the list. I'm not sure you can easy improve the query. Try to limit customers in this code:

 

$this->_join = '
      LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer` AND c.`id_customer` NOT LIKE '%P. Guest%')

Link to comment
Share on other sites

Thanks for reply tuk66, i try it but it gives me error "Table 'c56kopiluwakdb2.ps_ps_address' doesn't exist". I really don't understand why adding this condition change table name, but it does.

 

if the filter has a checkbox that turns negation search it would solve everything, but unfortunately doesn't ...

Link to comment
Share on other sites

Yes, error is gone :-) but nothing happend. If i change name P. Guest to customer id 4485, in order view i see same orders only in orders from P. Guest aren't names :-)

 

post-568339-0-49822300-1462175523_thumb.png  post-568339-0-42377500-1462175522_thumb.png

 

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