Crazy Alien
Crazy Alien

Reputation: 126

SuiteCRM add a custom search Query

I'm trying to figure it out how to create a text box in Products Module where i can put a clients name and with a query i built shows the prices of the product for that client. I have the query built and the table that relates the accounts with the products all i'm missing is how to do this customize search

Upvotes: 0

Views: 1613

Answers (1)

Crazy Alien
Crazy Alien

Reputation: 126

Ok guys I figured it out :)
In the include/LisView/ListViewData.php There's the query handling every data that a module might need for his list
go to this line:

$main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join']. $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];

here you see the query getting all rows from current module (products, accounts, contacts, ..) since this handles all modules make sure your changes only change the module you want like so:

if($this->seed->module_name == "AOS_Products"
     Your changes

OffTopic but very usefull in case you need extra info from another table like i did (account)
use the global variable db $accountPrice = $GLOBALS['db']->query("SELECT shipping_address_street as price FROM " ." accounts WHERE name LIKE '".$array[$try]."'"); $accountCodePrice = $GLOBALS['db']->fetchByAssoc($accountPrice);
Cheers

Upvotes: 1

Related Questions