/** * Export all baseline data feeds */ public function exportallAction() { // Validate configuration try { Mage::helper('mybuys')->validateFeedConfiguration(); } catch (Exception $e) { // Display message $this->_getSession()->addError($this->__($e->getMessage())); // Redirect back to index $this->_redirect('*/*/index'); return; } try { // Get ID from request $id = $this->getRequest()->getParam('id'); // Log Mage::log('Scheduling immediate baseline data feeds for all websites.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE); // Schedule all feeds for this site Mybuys_Connector_Model_Job::scheduleJobsAllWebsites(true); // Log Mage::log('Successfully scheduled feeds.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE); } catch (Exception $e) { // Log exception Mage::logException($e); Mage::log('Failed to schedule feeds.', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE); Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE); } // Display message once job scheduled $this->_getSession()->addSuccess($this->__('Baseline feed generation and transfer has been scheduled all websites.')); // Redirect back to index $this->_redirect('*/*/index'); }
/** * Grab the next job and run it, if it exists * * */ protected function runJob() { try { $job = Mybuys_Connector_Model_Job::getNextJobFromQueue(); if ($job !== false) { $job->run(); } } catch (Exception $e) { // Log exception Mage::logException($e); Mage::helper('mybuys')->log('Failed to run job, error:', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE); Mage::helper('mybuys')->log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE); throw $e; } }
/** * 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(); }