Actually I did not need an extension - all I was missing was a proper syntax of assignement:
$product->translation = array(new Translation, new Translation, new Translation);
Actually you can also use it in a slightly different way, say if you want to have those models pre filed with some attributes and even add new models to existing ones:
$new_obj = new Translation; //create an empty object
$new_object->language = 'English'; //set an attribute
$this->translation = array_merge($this->translation, array($new_obj)); //merge existing relations with a new one
The extension was not meant to assign the related object to the parent one, the purpose is more to save the related models with the parent model so instead of doing:
$product->translation = array(new Translation, new Translation, new Translation);
// save product
$product>save();
// save related models
foreach($product->translation as $tr ) {
$tr->product_id = $product->id; // set the foreign key
$tr->save();
}
you’ll have only to do
$product->translation = array(new Translation, new Translation, new Translation);
// Saving the product and automatically adding the 3 translations in the db with the product id
$product->save();