Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * Set the state of an entry
  *
  * @param      integer $state State to set
  * @return     void
  */
 public function stateTask($state = 0)
 {
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Check for an ID
     if (count($ids) < 1) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $state == 1 ? Lang::txt('COM_STOREFRONT_SELECT_PUBLISH') : Lang::txt('COM_STOREFRONT_SELECT_UNPUBLISH'), 'error');
         return;
     }
     foreach ($ids as $cId) {
         // Save category
         try {
             $collection = new Collection($cId);
             $collection->setActiveStatus($state);
             // Make sure there are no integrity issues
             $this->checkIntegrity($collection);
             $collection->save();
         } catch (\Exception $e) {
             $error = true;
         }
     }
     // Set message
     switch ($state) {
         case '-1':
             $message = Lang::txt('COM_STOREFRONT_ARCHIVED', count($ids));
             break;
         case '1':
             $message = Lang::txt('COM_STOREFRONT_PUBLISHED', count($ids));
             break;
         case '0':
             $message = Lang::txt('COM_STOREFRONT_UNPUBLISHED', count($ids));
             break;
     }
     $type = 'message';
     if (isset($error) && $error) {
         switch ($state) {
             case '1':
                 $action = 'published';
                 break;
             case '0':
                 $action = 'unpublished';
                 break;
         }
         $message = 'Collection could not be ' . $action;
         if (sizeof($ids) > 1) {
             $message = 'Some collection(s) could not be ' . $action;
         }
         $type = 'error';
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $message, $type);
 }