Public Member Functions | |
importRates () | |
fetchRates () | |
getMessages () | |
Protected Member Functions | |
_getCurrencyCodes () | |
_getDefaultCurrencyCodes () | |
_convert ($currencyFrom, $currencyTo) | |
_saveRates ($rates) | |
_numberFormat ($number) |
Definition at line 32 of file Abstract.php.
_convert | ( | $ | currencyFrom, | |
$ | currencyTo | |||
) | [abstract, protected] |
Retrieve rate
string | $currencyFrom | |
string | $currencyTo |
_getCurrencyCodes | ( | ) | [protected] |
Retrieve currency codes
Definition at line 39 of file Abstract.php.
00040 { 00041 return Mage::getModel('directory/currency')->getConfigAllowCurrencies(); 00042 }
_getDefaultCurrencyCodes | ( | ) | [protected] |
Retrieve default currency codes
Definition at line 49 of file Abstract.php.
00050 { 00051 return Mage::getModel('directory/currency')->getConfigBaseCurrencies(); 00052 }
_numberFormat | ( | $ | number | ) | [protected] |
_saveRates | ( | $ | rates | ) | [protected] |
Saving currency rates
array | $rates |
Definition at line 69 of file Abstract.php.
00070 { 00071 foreach ($rates as $currencyCode => $currencyRates) { 00072 Mage::getModel('directory/currency') 00073 ->setId($currencyCode) 00074 ->setRates($currencyRates) 00075 ->save(); 00076 } 00077 return $this; 00078 }
fetchRates | ( | ) |
Definition at line 92 of file Abstract.php.
00093 { 00094 $data = array(); 00095 $currencies = $this->_getCurrencyCodes(); 00096 $defaultCurrencies = $this->_getDefaultCurrencyCodes(); 00097 @set_time_limit(0); 00098 foreach ($defaultCurrencies as $currencyFrom) { 00099 if (!isset($data[$currencyFrom])) { 00100 $data[$currencyFrom] = array(); 00101 } 00102 00103 foreach ($currencies as $currencyTo) { 00104 if ($currencyFrom == $currencyTo) { 00105 $data[$currencyFrom][$currencyTo] = $this->_numberFormat(1); 00106 } 00107 else { 00108 $data[$currencyFrom][$currencyTo] = $this->_numberFormat($this->_convert($currencyFrom, $currencyTo)); 00109 } 00110 } 00111 ksort($data[$currencyFrom]); 00112 } 00113 00114 return $data; 00115 }
getMessages | ( | ) |
importRates | ( | ) |
Import rates
Definition at line 85 of file Abstract.php.
00086 { 00087 $data = $this->fetchRates(); 00088 $this->_saveRates($data); 00089 return $this; 00090 }