/**
  * @param $order
  * @param $product
  * @param $quantity
  * @param $user
  * @return User_order_details
  */
 public function createUserOrderDetailsItem($order, $product, $quantity, $user)
 {
     $userOrderDetails = new User_order_details();
     $userOrderDetails->setHostOrderId($order);
     $userOrderDetails->setProductId($product);
     $userOrderDetails->setQuantity($quantity);
     $userOrderDetails->setUserId($user);
     $this->getEntityManager()->persist($userOrderDetails);
     $this->getEntityManager()->flush();
     return $userOrderDetails;
 }
 public function load(ObjectManager $manager)
 {
     for ($i = 1; $i <= 5; $i++) {
         $userOrderDetails = new User_order_details();
         $userOrderDetails->setHostOrderId($this->getReference('hostOrder1'));
         $userOrderDetails->setProductId($this->getReference('product1'));
         $userOrderDetails->setQuantity(5);
         $userOrderDetails->setUserId($this->getReference("user{$i}"));
         $manager->persist($userOrderDetails);
         $manager->flush();
     }
 }
Esempio n. 3
0
 /**
  * @param $orderId
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function confirmAction($orderId)
 {
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $translator = $this->get('translator');
     $entityManager = $this->getDoctrine()->getManager();
     $session = $this->get('session');
     $cart = $this->get('cart.provider');
     $order = $this->getDoctrine()->getRepository('IlluminatiOrderBundle:Host_order')->find($orderId);
     $entityManager->getRepository('IlluminatiOrderBundle:User_order_details')->deleteAllUserOrderedDetails($user->getId(), $order->getId());
     foreach ($cart->getStorage() as $productId => $quantity) {
         $product = $cart->getItem($productId);
         $userOrderDetails = new User_order_details();
         $userOrderDetails->setHostOrderId($order);
         $userOrderDetails->setProductId($product);
         $userOrderDetails->setQuantity($quantity);
         $userOrderDetails->setUserId($user);
         $entityManager->persist($userOrderDetails);
     }
     $entityManager->flush();
     $session->remove('cart');
     $session->getFlashBag()->add('success', $translator->trans('cart.confirm_success'));
     return $this->redirectToRoute('host_order_summary', ['id' => $orderId]);
 }