protected function _prepareCollection()
 {
     // Build a collection representing each data feed for each website
     $collection = new Varien_Data_Collection();
     // Iterate websites and check configuration
     $websites = Mage::app()->getWebsites(false, true);
     foreach ($websites as $website) {
         // Grab id from website
         $websiteId = $website->getId();
         // Create Website Row in Grid
         if (Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/general/allfeedsenabled') == 'enabled') {
             // Lookup configuration for this site
             $feedTypes = '';
             foreach (Mybuys_Connector_Model_Generatefeeds::getFeedTypes() as $curFeedType) {
                 if (Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/feedsenabled/' . $curFeedType) == 'enabled') {
                     if (strlen($feedTypes) > 0) {
                         $feedTypes .= ', ';
                     }
                     $feedTypes .= $curFeedType;
                 }
             }
             $sftpUser = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/username');
             $sftpDestination = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/hostname');
             // Create and save grid item
             $newItem = $collection->getNewEmptyItem();
             $newItem->setData(array('id' => $website->getId(), 'website_name' => $website->getName(), 'website_code' => $website->getCode(), 'feeds' => $feedTypes, 'sftp_destination' => $sftpDestination, 'sftp_user' => $sftpUser));
             $collection->addItem($newItem);
         }
     }
     $this->setCollection($collection);
     return $this;
 }
 /**
  * Schedule baseline or incremental daily jobs to run immediately
  *
  *
  */
 public static function scheduleJobs($websiteId, $bBaselineFile)
 {
     // Log
     Mage::helper('mybuys')->log('Scheduling jobs for website: ' . $websiteId, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
     Mage::helper('mybuys')->log('All feeds for website set to: ' . Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/general/allfeedsenabled'), Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
     // Local to hold last job id
     $lastJobId = null;
     // Check if data feeds enabled
     if (Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/general/allfeedsenabled') != 'enabled') {
         return;
     }
     // Create generate jobs for all enabled feeds
     foreach (Mybuys_Connector_Model_Generatefeeds::getFeedTypes() as $curType) {
         // Create feed job of this type if config is enabled
         if (Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/feedsenabled/' . $curType) == 'enabled') {
             // Check baseline or daily
             $jobType = 0;
             if ($bBaselineFile) {
                 $jobType = Mybuys_Connector_Model_Job::TYPE_GENERATE_BASELINE;
             } else {
                 $jobType = Mybuys_Connector_Model_Job::TYPE_GENERATE_DAILY;
             }
             // Create feed job
             $job = Mybuys_Connector_Model_Job::createJob($lastJobId, $websiteId, $jobType, $curType);
             $job->save();
             $lastJobId = $job->getJobId();
         }
     }
     // Create transfer feeds job for this website
     $job = Mybuys_Connector_Model_Job::createJob($lastJobId, $websiteId, Mybuys_Connector_Model_Job::TYPE_TRANSFER, NULL);
     $job->save();
 }