Mage_Directory_Model_Observer Class Reference

List of all members.

Public Member Functions

 scheduledUpdateCurrencyRates ($schedule)

Public Attributes

const CRON_STRING_PATH = 'crontab/jobs/currency_rates_update/schedule/cron_expr'
const IMPORT_ENABLE = 'currency/import/enabled'
const IMPORT_SERVICE = 'currency/import/service'
const XML_PATH_ERROR_TEMPLATE = 'currency/import/error_email_template'
const XML_PATH_ERROR_IDENTITY = 'currency/import/error_email_identity'
const XML_PATH_ERROR_RECIPIENT = 'currency/import/error_email'


Detailed Description

Directory module observer

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 32 of file Observer.php.


Member Function Documentation

scheduledUpdateCurrencyRates ( schedule  ) 

Definition at line 42 of file Observer.php.

00043     {
00044         $importWarnings = array();
00045         if(!Mage::getStoreConfig(self::IMPORT_ENABLE) || !Mage::getStoreConfig(self::CRON_STRING_PATH)) {
00046             return;
00047         }
00048 
00049         $service = Mage::getStoreConfig(self::IMPORT_SERVICE);
00050         if( !$service ) {
00051             $importWarnings[] = Mage::helper('directory')->__('FATAL ERROR:') . ' ' . Mage::helper('directory')->__('Invalid Import Service Specified');
00052         }
00053 
00054         try {
00055             $importModel = Mage::getModel(Mage::getConfig()->getNode('global/currency/import/services/' . $service . '/model')->asArray());
00056         } catch (Exception $e) {
00057             $importWarnings[] = Mage::helper('directory')->__('FATAL ERROR:') . ' ' . Mage::throwException(Mage::helper('directory')->__('Unable to initialize import model'));
00058         }
00059 
00060         $rates = $importModel->fetchRates();
00061         $errors = $importModel->getMessages();
00062 
00063         if( sizeof($errors) > 0 ) {
00064             foreach ($errors as $error) {
00065                 $importWarnings[] = Mage::helper('directory')->__('WARNING:') . ' ' . $error;
00066             }
00067         }
00068 
00069         if (sizeof($importWarnings) == 0) {
00070             Mage::getModel('directory/currency')->saveRates($rates);
00071         }
00072         else {
00073             $translate = Mage::getSingleton('core/translate');
00074             /* @var $translate Mage_Core_Model_Translate */
00075             $translate->setTranslateInline(false);
00076 
00077             /* @var $mailTemplate Mage_Core_Model_Email_Template */
00078             $mailTemplate = Mage::getModel('core/email_template');
00079             $mailTemplate->setDesignConfig(array(
00080                 'area'  => 'frontend',
00081             ))->sendTransactional(
00082                 Mage::getStoreConfig(self::XML_PATH_ERROR_TEMPLATE),
00083                 Mage::getStoreConfig(self::XML_PATH_ERROR_IDENTITY),
00084                 Mage::getStoreConfig(self::XML_PATH_ERROR_RECIPIENT),
00085                 null,
00086                 array(
00087                     'warnings'    => join("\n", $importWarnings),
00088                 )
00089             );
00090 
00091             $translate->setTranslateInline(true);
00092         }
00093     }


Member Data Documentation

const CRON_STRING_PATH = 'crontab/jobs/currency_rates_update/schedule/cron_expr'

Definition at line 34 of file Observer.php.

const IMPORT_ENABLE = 'currency/import/enabled'

Definition at line 35 of file Observer.php.

const IMPORT_SERVICE = 'currency/import/service'

Definition at line 36 of file Observer.php.

const XML_PATH_ERROR_IDENTITY = 'currency/import/error_email_identity'

Definition at line 39 of file Observer.php.

const XML_PATH_ERROR_RECIPIENT = 'currency/import/error_email'

Definition at line 40 of file Observer.php.

const XML_PATH_ERROR_TEMPLATE = 'currency/import/error_email_template'

Definition at line 38 of file Observer.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:07 2009 for Magento by  doxygen 1.5.8