public function addAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $coreManager = $this->get('core_manager');
        $checkoutManager = $this->get('checkout_manager');
        $cart = $this->getCurrentCart();
        $emptyItem = new CartItem();
        
        try {
            $item = $checkoutManager->resolve($emptyItem, $request);
        } catch (\Exception $exception) {
            // Write flash message
            print_r($exception->getMessage());die();
            return $this->redirect($this->generateUrl('ecommerce_checkout_detail'));
        }

        $price = $item->getProduct()->getPrice();
        $item->setUnitPrice($price);
        $freeTransport = $item->getProduct()->isFreeTransport();
        $item->setFreeTransport($freeTransport);
        //add
        $cart->addItem($item);
        //refresh
        $cart->calculateTotal();
        $cart->setTotalItems($cart->countItems());
        //save
        $em->persist($cart);
        $em->flush();
       
        // Write flash message
        $referer = $coreManager->getRefererPath($request);
        return $this->redirect($this->generateUrl('ecommerce_checkout_detail').'?referer='.$referer);
    }