通过逻辑挂钩我试图在发票保存后更新我的产品字段。在SuiteCRM中的发票逻辑挂钩中获取行项目
到目前为止,我所了解的是,我需要获取与AOS_Products_Quotes有关的发票,并从那里获得产品,更新必填字段并保存产品。那个听起来是对的吗?
逻辑挂钩正在触发,但关系不会加载。
function decrement_stocks ($bean, $event, $arguments) {
//$bean->product_value_c = $bean->$product_unit_price * $bean->product_qty;
$file = 'custom/modules/AOS_Invoices/decrement.txt';
// Get the Invoice ID:
$sInvoiceID = $bean->id;
$oInvoice = new AOS_Invoices();
$oInvoice->retrieve($sInvoiceID);
$oInvoice->load_relationship('aos_invoices_aos_product_quotes');
$aProductQuotes = $oInvoice->aos_invoices_aos_product_quotes->getBeans();
/*
$aLineItemslist = array();
foreach ($oInvoice->aos_invoices_aos_product_quotes->getBeans() as $lineitem) {
$aLineItemslist[$lineitem->id] = $lineitem;
}
*/
$sBean = var_export($bean, true);
$sInvoice = var_export($oInvoice, true);
$sProductQuotes = var_export($aProductQuotes, true);
$current = $sProductQuotes . "\n\n\n------\n\n\n" . $sInvoice . "\n\n\n------\n\n\n" . $sBean;
file_put_contents($file, $current);
}
发票正在检索就好。但是load_relationship
没有做任何事情($ sInvoice没有更改,也没有更改)并且$aProductQuotes
为空。
我正在使用SuiteCRM 7.8.3,并在7.9.1上尝试过,但没有成功。我究竟做错了什么?