Public Member Functions | |
indexAction () | |
fetchRatesAction () | |
saveRatesAction () | |
Protected Member Functions | |
_initCurrency () | |
_isAllowed () |
Definition at line 34 of file CurrencyController.php.
_initCurrency | ( | ) | [protected] |
Init currency by currency code from request
Definition at line 41 of file CurrencyController.php.
00042 { 00043 $code = $this->getRequest()->getParam('currency'); 00044 $currency = Mage::getModel('directory/currency') 00045 ->load($code); 00046 00047 Mage::register('currency', $currency); 00048 return $this; 00049 }
_isAllowed | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Controller_Action.
Definition at line 119 of file CurrencyController.php.
00120 { 00121 return Mage::getSingleton('admin/session')->isAllowed('system/currency'); 00122 }
fetchRatesAction | ( | ) |
Definition at line 62 of file CurrencyController.php.
00063 { 00064 try { 00065 $service = $this->getRequest()->getParam('rate_services'); 00066 $this->_getSession()->setCurrencyRateService($service); 00067 if( !$service ) { 00068 throw new Exception(Mage::helper('adminhtml')->__('Invalid Import Service Specified')); 00069 } 00070 try { 00071 $importModel = Mage::getModel(Mage::getConfig()->getNode('global/currency/import/services/' . $service . '/model')->asArray()); 00072 } catch (Exception $e) { 00073 Mage::throwException(Mage::helper('adminhtml')->__('Unable to initialize import model')); 00074 } 00075 $rates = $importModel->fetchRates(); 00076 $errors = $importModel->getMessages(); 00077 if( sizeof($errors) > 0 ) { 00078 foreach ($errors as $error) { 00079 Mage::getSingleton('adminhtml/session')->addWarning($error); 00080 } 00081 Mage::getSingleton('adminhtml/session')->addWarning(Mage::helper('adminhtml')->__('All possible rates were fetched, click on "Save" to apply')); 00082 } else { 00083 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('All rates were fetched, click on "Save" to apply')); 00084 } 00085 00086 Mage::getSingleton('adminhtml/session')->setRates($rates); 00087 } 00088 catch (Exception $e){ 00089 Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); 00090 } 00091 $this->_redirect('*/*/'); 00092 }
indexAction | ( | ) |
Currency management main page
Definition at line 54 of file CurrencyController.php.
00055 { 00056 $this->loadLayout(); 00057 $this->_setActiveMenu('system/currency'); 00058 $this->_addContent($this->getLayout()->createBlock('adminhtml/system_currency')); 00059 $this->renderLayout(); 00060 }
saveRatesAction | ( | ) |
Definition at line 94 of file CurrencyController.php.
00095 { 00096 $data = $this->getRequest()->getParam('rate'); 00097 if( is_array($data) ) { 00098 try { 00099 foreach ($data as $currencyCode => $rate) { 00100 foreach( $rate as $currencyTo => $value ) { 00101 $value = abs(Mage::getSingleton('core/locale')->getNumber($value)); 00102 $data[$currencyCode][$currencyTo] = $value; 00103 if( $value == 0 ) { 00104 Mage::getSingleton('adminhtml/session')->addWarning(Mage::helper('adminhtml')->__('Invalid input data for %s => %s rate', $currencyCode, $currencyTo)); 00105 } 00106 } 00107 } 00108 00109 Mage::getModel('directory/currency')->saveRates($data); 00110 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('All valid rates successfully saved')); 00111 } catch (Exception $e) { 00112 Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); 00113 } 00114 } 00115 00116 $this->_redirect('*/*/'); 00117 }