Hi I have a many to many relation between Items(Products) and categories and I implemented using these three entities:
Item Entity:
/**
* @
First, you should rename ItemCategories by ItemCategory, since an instance of this item is only the link between 1 item and 1 category.
Then it's simple:
$item = new Item();
$em->persist($item);
$category = $em->getRepository('category')->find($id_category);
$itemCategory =new ItemCategory();
$itemCategory->setItem($item);
$itemCategory->setCategory($category);
$em->persist($itemCategory);