AnsweredAssumed Answered

Link Many To Many With Bean

Question asked by Paul Carlton on Nov 18, 2015
Latest reply on Nov 25, 2015 by Paul Carlton

Hi!  I've written some code that doesn't appear to be functioning as I would hope.  Perhaps someone can give me a quick pointer.

 

Currently I have:

 

$Account = new \Account();
$Account->retrieve($vendor_id);
$Account->load_relationship('accounts_accounts_1');
$Account->accounts_accounts_1->add($account_id);
$Account->save();

 

This does not appear to work.  If I check the database I do not find the related record after I run this.  Am I missing something important with adding a Many to Many relationship to an account (or any module for that matter)?  I do know this!  Running it gives no errors on the screen, no errors in the logs.  I know the name of the custom module is "accounts_accounts_1" as defined in studio.  I know that to add relationships I would do it this way programmatically.

 

To be quite frank, the module is very simple and I don't see much extension of it.  It's purpose is purely to link accounts to accounts.  I could write a very simple SQL to make this work for me but I would prefer to figure out why this bit of code does not work for this custom relationship.

 

Thanks,

Outcomes