通過邏輯掛鉤我試圖在發票保存後更新我的產品字段。在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上嘗試過,但沒有成功。我究竟做錯了什麼?