/** * Get a collection * * @param int collection ID * @return StorefrontModelCollection Instance of a collection */ public function getCollection($cId) { $collection = new Collection(); // Get all product info $collectionInfo = $this->getCollectionInfo($cId, true); //print_r($collectionInfo); die; $collection->setType($collectionInfo->cType); $collection->setId($collectionInfo->cId); $collection->setName($collectionInfo->cName); $collection->setActiveStatus($collectionInfo->cActive); $collection->verify(); return $collection; }
/** * Save a collection * * @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'); // Get the collection $collection = new Collection($fields['cId']); try { if (isset($fields['cName'])) { $collection->setName($fields['cName']); } if (isset($fields['state'])) { $collection->setActiveStatus($fields['state']); } if (isset($fields['alias'])) { $collection->setAlias($fields['alias']); } $collection->setType('category'); // Make sure there are no integrity issues $this->checkIntegrity($collection); $collection->save(); } catch (\Exception $e) { \Notify::error($e->getMessage()); $this->editTask($collection); return; } if ($redirect) { // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_STOREFRONT_COLLECTION_SAVED')); return; } $this->editTask($collection); }