/** * Initialization **/ public function init() { $this->model = getModel('shop'); $this->shop = $this->model->getShop($this->module_info->module_srl); if(preg_match("/ShopTool/",$this->act) ) { $this->initTool($this); } else { $this->initService($this); } }
/** * cart add product * @return Object */ public function procShopToolCartAddProduct() { $cartRepository = new CartRepository(); if ($product_srl = Context::get('product_srl')) { $productsRepo = new ProductRepository(); if ($product = $productsRepo->getProduct($product_srl)) { if (!($product instanceof SimpleProduct)) { return new Object(-1, 'msg_invalid_request'); } $logged_info = Context::get('logged_info'); $cart = $cartRepository->getCart($this->module_info->module_srl, NULL, $logged_info->member_srl, session_id(), TRUE); $quantity = (is_numeric(Context::get('quantity')) && Context::get('quantity') > 0 ? Context::get('quantity') : 1); try { $cart->addProduct($product, $quantity); } catch (Exception $e) { return new Object(-1, $e->getMessage()); } } else return new Object(-1, 'msg_invalid_request'); } else return new Object(-1, 'msg_invalid_request'); $shop = $this->model->getShop($this->module_srl); $this->setRedirectUrlIfNoReferer(getSiteUrl($shop->domain)); }