Mage_Directory_Model_Currency_Import_Abstract Class Reference

Inheritance diagram for Mage_Directory_Model_Currency_Import_Abstract:

Mage_Directory_Model_Currency_Import_Webservicex

List of all members.

Public Member Functions

 importRates ()
 fetchRates ()
 getMessages ()

Protected Member Functions

 _getCurrencyCodes ()
 _getDefaultCurrencyCodes ()
 _convert ($currencyFrom, $currencyTo)
 _saveRates ($rates)
 _numberFormat ($number)


Detailed Description

Abstract model for import currency

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

Definition at line 32 of file Abstract.php.


Member Function Documentation

_convert ( currencyFrom,
currencyTo 
) [abstract, protected]

Retrieve rate

Parameters:
string $currencyFrom
string $currencyTo
Returns:
float

_getCurrencyCodes (  )  [protected]

Retrieve currency codes

Returns:
array

Definition at line 39 of file Abstract.php.

00040     {
00041         return Mage::getModel('directory/currency')->getConfigAllowCurrencies();
00042     }

_getDefaultCurrencyCodes (  )  [protected]

Retrieve default currency codes

Returns:
array

Definition at line 49 of file Abstract.php.

00050     {
00051         return Mage::getModel('directory/currency')->getConfigBaseCurrencies();
00052     }

_numberFormat ( number  )  [protected]

Definition at line 117 of file Abstract.php.

00118     {
00119         return $number;
00120     }

_saveRates ( rates  )  [protected]

Saving currency rates

Parameters:
array $rates
Returns:
Mage_Directory_Model_Currency_Import_Abstract

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 (  ) 

Definition at line 122 of file Abstract.php.

00123     {
00124         return $this->_messages;
00125     }

importRates (  ) 

Import rates

Returns:
Mage_Directory_Model_Currency_Import_Abstract

Definition at line 85 of file Abstract.php.

00086     {
00087         $data = $this->fetchRates();
00088         $this->_saveRates($data);
00089         return $this;
00090     }


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