Ejemplo n.º 1
0
 /**
  * Set the request.
  *
  * @param ZenMagick\Http\Request request The request.
  */
 public function setRequest(Request $request)
 {
     $this->request = $request;
     $this->languageId = $request->getSession()->getLanguageId();
 }
Ejemplo n.º 2
0
 /**
  * Update cart.
  * @todo: edit cart attributes
  */
 public function updateAction(Request $request)
 {
     $flashBag = $request->getSession()->getFlashBag();
     $shoppingCart = $this->get('shoppingCart');
     $productIds = (array) $request->request->get('products_id');
     $quantities = (array) $request->request->get('cart_quantity');
     foreach ($productIds as $ii => $productId) {
         $shoppingCart->updateProduct($productId, $quantities[$ii]);
     }
     $this->container->get('event_dispatcher')->dispatch('cart_update', new GenericEvent($this, array('request' => $request, 'shoppingCart' => $shoppingCart, 'productIds' => $productIds)));
     $flashBag->success($this->get('translator')->trans('Product(s) added to cart'));
     // TODO: add support for redirect back to origin
     return new ModelAndView('success', array('shoppingCart' => $shoppingCart));
 }