Hey all,
I'm running SugarPro 6.2, and the standard quotes save routine doesn't relate a product line item to the account of a quote, like I would like to. I'm working on a before_save logic hook in the quotes module (although an after save will work too) but I'm getting an odd error with it. Here's my code:The customer_account_id is an extended field, but for the purposes of this example it really doesn't matter, the error occurs on the $product->save() with or without that line. Furthermore, this error only occurs when saving the quote; it doesn't occur when I save the product from the Products module.PHP Code:function modifyProducts($bean, $event, $arguments) {
$GLOBALS['log']->info("Entering custom logic hook modifyProducts for Quotes");
//resave all related products to reflect new changes in quote
$related_products = $bean->get_linked_beans('products', 'Product');
foreach($related_products as $product) {
$product->account_id = $bean->customer_account_id;
$product->save();
}
$GLOBALS['log']->info("Exiting custom logic hook for Quotes");
}
The issue is that whenever I save a product that has a non percent discount and a multiple quantity (i.e. a $150 item with a $50 discount per item and quantity 5) sugar saves the bundle as if it were to have a singular quantity (in the above example, the total for the bundle ends up as 150*5 - 50 = 700 rather than 150*5 - 5*50 = 500).
I'm wondering if anyone else has run into this issue, what's causing it, and most importantly if there's a way to fix it without having to recalculate the product bundle in a before_save logic hook (which would be highly inefficient).


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks