First I will give the short version:
$vnd = BeanFactory::getBean(‘vnd_Vendors’)->retrieve_by_string_fields(array(‘name’=>$bean->vnd_vendors_po_purchase_orders_1_name));
Returns an error stating that: The Class vnd_Vendors is not found. I have tried every iteration of this. vnd_vendors, vendors, Vendors, etc.
Long version.
Module po_purchase_orders has a One to Many relationship with Module vnd_vendors
One Vendor Many Purchase Orders
Purchase Order has a relate field with Vendors. The Sub Panel of Purchase Orders in Vendors never shows any Purchase Orders. (Shouldn’t this be automatic?)
I thought using a logic hook to create the relationship would work. But the line of code keeps telling me that there is no Class (Do they mean module?) called vnd_Vendors.
I was successful in doing this with stock modules but not with custom modules.
What am I doing wrong?
function relateVendor($bean, $event, $arguments){
if (!empty($bean->vnd_vendors_po_purchase_orders_1_name)){
$vnd = BeanFactory::getBean('vnd_Vendors')->retrieve_by_string_fields(array('name'=>$bean->vnd_vendors_po_purchase_orders_1_name));
$id = $vnd->id;
$GLOBALS['log']->error($ven);
$bean->load_relationship('vnd_vendors_po_purchase_orders_1');
$bean->accounts->add($id);
}
}