/** * 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'); //var_dump((($fields['pAlias']))); die; $obj = new Archive(); // Save product try { $product = new Product($fields['pId']); if (isset($fields['pName'])) { $product->setName($fields['pName']); } if (isset($fields['pAlias']) && $fields['pAlias']) { $product->setAlias($fields['pAlias']); } if (isset($fields['pDescription'])) { $product->setDescription($fields['pDescription']); } if (isset($fields['pFeatures'])) { $product->setFeatures($fields['pFeatures']); } if (isset($fields['pTagline']) && $fields['pTagline']) { $product->setTagline($fields['pTagline']); } if (isset($fields['access'])) { $product->setAccessLevel($fields['access']); } if (isset($fields['state'])) { $product->setActiveStatus($fields['state']); } if (isset($fields['ptId'])) { $product->setType($fields['ptId']); } if (isset($fields['pAllowMultiple'])) { $product->setAllowMultiple($fields['pAllowMultiple']); } if (!isset($fields['collections'])) { $fields['collections'] = array(); } $product->setCollections($fields['collections']); if (!isset($fields['optionGroups'])) { $fields['optionGroups'] = array(); } $product->setOptionGroups($fields['optionGroups']); $product->save(); } catch (\Exception $e) { \Notify::error($e->getMessage()); // Get the product //$product = $obj->product($fields['pId']); $this->editTask($product); return; } $warnings = $product->getMessages(); if ($warnings && !$redirect) { foreach ($warnings as $warning) { \Notify::warning($warning); } } if ($redirect) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller), Lang::txt('COM_STOREFRONT_PRODUCT_SAVED')); if ($warnings) { foreach ($warnings as $warning) { \Notify::warning($warning); } } return; } $this->editTask($product); }