Skip to content

Instantly share code, notes, and snippets.

@theodesp
Created December 7, 2019 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theodesp/d7bc05cfc290a98e9938053aebbf2972 to your computer and use it in GitHub Desktop.
Save theodesp/d7bc05cfc290a98e9938053aebbf2972 to your computer and use it in GitHub Desktop.
$entityManager = $this->getDoctrine()->getManager();
$product = new \App\Entity\Product();
$product->setId(1000);
$product->setPrice(1000);
$product->translate('de')->setName('Schuhe');
$product->translate('de')->setDescription('Schuhe');
$product->translate('en')->setName('Shoes');
$product->translate('en')->setDescription('Shoes');
$entityManager->persist($product);
// In order to persist new translations, call mergeNewTranslations method, before flush
$product->mergeNewTranslations();
$entityManager->flush();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment