/**
  * @return \WHO\WhoShop\Domain\Model\Order
  * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
  */
 private function saveOrder()
 {
     $newOrder = new \WHO\WhoShop\Domain\Model\Order();
     $newOrder->setUser($this->frontendUserRepository->findById($GLOBALS['TSFE']->fe_user->user['uid']));
     $newOrder->setOrderDate(time());
     $newOrder->setState(1);
     $this->orderRepository->add($newOrder);
     $this->persistenceManager->persistAll();
     foreach ($this->basketHandler->getOrder() as $productUid => $orderParams) {
         if ($productUid == 'count') {
             continue;
         }
         $newOrderItem = new \WHO\WhoShop\Domain\Model\OrderItem();
         $newOrderItem->setOrderSize($orderParams['orderSize']);
         $newOrderItem->setorderValue($orderParams['orderValue']);
         DebuggerUtility::var_dump($productUid);
         $newOrderItem->addProduct($this->productRepository->findById($productUid)->getFirst());
         $this->orderItemRepository->add($newOrderItem);
         $this->persistenceManager->persistAll();
         $newOrder->addOrderItem($newOrderItem);
         $this->orderRepository->update($newOrder);
         $this->persistenceManager->persistAll();
     }
     return $newOrder;
 }
 /**
  * @return string
  */
 public function ajaxAction()
 {
     $success = FALSE;
     $basketCount = 0;
     $product = $this->request->getArgument('product');
     $orderSize = $this->request->getArgument('ordersize');
     $forwarAction = $this->request->getArgument('forwardAction');
     if ($product != 0) {
         switch ($forwarAction) {
             case 'addToBasket':
                 $success = $this->addToBasket($this->productRepository->findByUid($product), $orderSize);
                 break;
             case 'removeFromBasket':
                 $success = $this->removeFromBasket($this->productRepository->findByUid($product));
                 break;
             case 'updateOrderSize':
                 $success = $this->updateOrderSize($product, $orderSize);
                 break;
         }
         $basketCount = $this->basketHandler->getOrder();
     }
     return json_encode(array('success' => $success, 'basketcount' => '4'));
 }