I’m trying to figure out the best way to go about changing the pricing logic since this is the first time I make such a “big” customization. Instead of using the product price provided by the builtin functionality, I need to make an api call to our erp instead (we have complex pricing). I’ve created a PHP wrapper class for our erp api’s because they were overly complex and I wanted to simplify them. Where should I put this class and how would I access it from line_items.js using the “proper” sugarcrm/suitecrm methodology? Thanks for your help.
Create a new table linking the products with the price I had to do this because my products changed price with the account priceNumber my new table:
CREATE TABLE IF NOT EXISTS `accounts_products` (
`id` varchar(255) NOT NULL,
`id_preco_venda` int(10) DEFAULT NULL,
`id_product` varchar(255) DEFAULT NULL,
`cost` decimal(26,6) DEFAULT '0.000000' COMMENT 'custo para cliente',
`visivel` varchar(6) NOT NULL DEFAULT 'false',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
then you can go to the query source of the list view [color=#0000ff]include\ListView\ListViewData.php[/color] and look for this variable “$main_query = $ret_array[‘select’] .”
this holds the full query that gets all data to the list view of all modules that require a list view so to make changes in the AOS_products module only
if($this->seed->module_name == "AOS_Products)"
and now you can alter that query as you want LIKE LEFT JOIN to your new table of price and change the “aos_products.price” to the new table price
Cheers
This is exactly what I am trying to avoid. I cannot extract pricing from the erp and create a pricing table because it is simply too complicated. Our current system does that and it is a nightmare to manage. What I was thinking of doing is making a js ajax call to a custom entry point that connects to my erp api class. I guess I can also modify the file you mentioned to get the price from the api instead but that would not be upgrade safe. Any other suggestions?
So all in all you just want to run a php file that you already built the only problem is requiring it?
if that’s what happen then you need to know you can require any file within the program but ajax calls can’t because the htaccess file blocks the word module but you can always give an entryPoint to your file like this:
go to [color=#0000ff]custom\Extension\application\Ext\EntryPointRegistry[/color]
and create a new file and name it like your php file with your class
and write this array:
$entry_point_registry['YourFileName'] = array(
'file' => 'modules/AOS_Products/YourFileName.php',
'auth' => true
);
assuming your file is in the [color=#0000ff]modules/AOS_Products[/color] directory
Then just do a QuickRepair&Rebuild for the program to write the new file with entryPoint
And in the ajax casll the url will be
url: "index.php?entryPoint=YourFileName",
type: "GET",
dataType: "json",
And your php file add this code on top
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
Hope it helped
Thanks for the response Craazy. That is pretty much what I wanted to do but I wasn’t sure if that was the “correct” approach to my problem. Seems to be working fine. Thanks again.