/** * Remove an entry * * @return void */ public function removeTask() { // Incoming $step = Request::getInt('step', 1); $step = !$step ? 1 : $step; // What step are we on? switch ($step) { case 1: Request::setVar('hidemainmenu', 1); // Incoming $id = Request::getVar('id', array(0)); if (!is_array($id) && !empty($id)) { $id = array($id); } $this->view->pIds = $id; // Set any errors if ($this->getError()) { $this->view->setError($this->getError()); } // Output the HTML $this->view->display(); break; case 2: // Check for request forgeries Request::checkToken() or jexit('Invalid Token'); // Incoming $pIds = Request::getVar('pIds', 0); //print_r($sId); die; // Make sure we have IDs to work with if (empty($pIds)) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller), Lang::txt('COM_STOREFRONT_NO_ID'), 'error'); return; } $delete = Request::getVar('delete', 0); $msg = "Delete canceled"; $type = 'error'; if ($delete) { // Do the delete $obj = new Archive(); foreach ($pIds as $pId) { // Delete SKU try { $product = $obj->product($pId); $product->delete(); } catch (\Exception $e) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=dispaly&id=' . $pId), $e->getMessage(), $type); return; } } $msg = "Product(s) deleted"; $type = 'message'; } // Set the redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=dispaly&id=' . $pId), $msg, $type); break; } }
/** * Save a product * * @param boolean $redirect Redirect the page after saving * @return void */ public function saveTask($redirect = true) { // Check for request forgeries Request::checkToken() or jexit('Invalid Token'); // Incoming $fields = Request::getVar('fields', array(), 'post'); $obj = new Archive(); // Save product try { $obj->setProductMeta($fields['pId'], $fields); } catch (\Exception $e) { \Notify::error($e->getMessage()); // Get the product $product = $obj->product($fields['pId']); $this->editTask($product); return; } if ($redirect) { // Redirect $this->setRedirect('index.php?option=' . $this->_option . '&controller=products&task=edit&id=' . Request::getInt('id', 0), Lang::txt('COM_STOREFRONT_PRODUCT_SAVED')); return; } // Get the product $product = $obj->product($fields['pId']); $this->editTask($product); }
/** * Save a product * * @param boolean $redirect Redirect the page after saving * @return void */ public function saveTask($redirect = true) { // Check for request forgeries Request::checkToken() or jexit('Invalid Token'); // Incoming $fields = Request::getVar('fields', array(), 'post'); $obj = new Archive(); // Get the product $product = $obj->product($fields['pId']); $meta = $fields; unset($meta['pId']); // Save product meta $product->setMeta($meta); if ($redirect) { // Redirect $this->setRedirect('index.php?option=' . $this->_option . '&controller=products&task=edit&id=' . Request::getInt('id', 0), Lang::txt('COM_STOREFRONT_PRODUCT_SAVED')); return; } $this->editTask($product); }