Add relationship

I am trying to add a relationship to the factory created relationship of (project & quotes) many to many.

I am doing this inside an aftersave logic hook of the quotes module.

   $project = BeanFactory::getBean('Project')->retrieve_by_string_fields(array('name'=>$bean->project_id_c));
          $bean->load_relationship('quotes');
          $bean->quotes->add('$project');

project_id_c is a relate field.

I have tried several versions of this and I can’t seem to find anything that works.

Are you sure that’s the name of the relationship?

Check this sample. It should give a good idea on how it works:
http://cheleguanaco.blogspot.com/2012/03/sugarcrm-cookbook-adding-related.html

Thanks,

AlxGr