_model = new OrderModel(); parent::initController($request, $response, $logger); $this->_viewPath .= strtolower($this->_model->getClassName()); } //장바구니에 담기 public function insert() { $msg = ""; try { $this->_viewDatas['fields'] = $this->_model->getFields(__FUNCTION__); $this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], __FUNCTION__); //Transaction 시작 $this->_model->transStart(); $this->insert_process(); $this->_model->addCart($this->_viewDatas['fieldDatas']); //Transaction Commit $this->_model->transCommit(); $msg = sprintf( "%s에서 해당 상품 %s개를 장바구니에 담았습니다.", $this->_viewDatas['title'], $this->_viewDatas['fieldDatas']['quantity'] ); return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL'])); } catch (\Exception $e) { //Transaction Rollback $this->_model->transRollback(); log_message("error", $e->getMessage()); log_message("error", var_export($this->_viewDatas['fieldDatas'], true)); $msg = sprintf( "%s에서 다음 오류로 인해 장바구니에 담기를 실패하였습니다.\n%s", $this->_viewDatas['title'], $e->getMessage() ); return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL'])); } finally { $this->_session->setFlashdata("return_message", $msg); } } }