I'm working on synchronization entities from one DB to another. I have entities mapped for ORM and ODM, like:
/*
* @ODM\Document(
* repositoryClass="App\Lib\Repositories\ProductRepository",
* collection="products"
* )
* @ODM\InheritanceType("COLLECTION_PER_CLASS")
*
* @ORM\Entity(
* repositoryClass="App\Lib\Repositories\Legacy\LegacyProductRepository"
* )
* @ORM\Table(name="product")
*
* @ORM\HasLifecycleCallbacks()
* @ODM\HasLifecycleCallbacks()
*/
class Product extends Article
It works nice, but I would like to load entity from document manager from mongo db and save it to ORM:
$product = $this->documentManager->find(Product::class, $id);
$this->entityManager->merge($product);
$this->entityManager->flush();
But I have an issue with relations. How do I persist related entity (such as ProductAction) with merging a product?