sidebar = $sidebar; $this->logger = $logger; $this->jsonHelper = $jsonHelper; parent::__construct($context); } /** * @return $this */ public function execute() { $itemId = (int)$this->getRequest()->getParam('item_id'); $itemQty = $this->getRequest()->getParam('item_qty') * 1; try { $this->sidebar->checkQuoteItem($itemId); $this->sidebar->updateQuoteItem($itemId, $itemQty); return $this->jsonResponse(); } catch (LocalizedException $e) { return $this->jsonResponse($e->getMessage()); } catch (\Exception $e) { $this->logger->critical($e); return $this->jsonResponse($e->getMessage()); } } /** * Compile JSON response * * @param string $error * @return Http */ protected function jsonResponse($error = '') { return $this->getResponse()->representJson( $this->jsonHelper->jsonEncode($this->sidebar->getResponseData($error)) ); } }