1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| /**
* @Route("/panier/ajouter/{productId}", name="addPanier")
* @param $productId
* @param SessionInterface $session
* @return string
*/
public function ajouterPanierAction($productId, SessionInterface $session)
{
$em = $this->getDoctrine()->getManager();
$panier = $session->get('panier', []);
$productRepository = $em->getRepository("AppBundle:Product");
$product = $productRepository->find($productId);
$panier[] = $product;
//ajouter au "panier" ce l'item en question
return $this->generateUrl("panier", ["panier" => $panier]);
} |
Partager