This part of the 4.x documentation is for eZ Publish 4.0, only reference section is common for all eZ Publish 4.x versions as well as eZ Publish 5.x "LegacyStack", please select the version you are using for the most up to date documentation! |
The exchange rates update handlers make it possible to retrieve the latest exchange rates from external sources and thus update the auto rates. You should specify the desired handler in the "ExchangeRatesUpdateHandler" setting described in the next subsection, otherwise the system will not be able to update the auto rates. You can either use the built-in "eZECB" handler for getting the exchange rates from the website of the European Central Bank or extend the system by creating your own update handler.
The "[ExchangeRatesSettings]" section of the "settings/shop.ini" configuration file defines the update handler that will be used for updating auto rates. Under this section, the following settings can be specified:
The "[ECBExchangeRatesSettings]" section of the "settings/shop.ini" configuration file defines the specific settings for the "eZECB" update handler. The combination of the "ServerName", "ServerPort" and "RatesURI" settings allows to specify the exact address of the XML file containing the currency rates.
The following lines can be specified in the "[ExchangeRatesSettings]" section of the "shop.ini" configuration file:
ExchangeRatesUpdateHandler=eZECB RepositoryDirectories[]=kernel/shop/classes/exchangeratehandlers ExtensionDirectories[] BaseCurrency=EUR
These settings will instruct eZ Publish to use the built-in update handler located at"kernel/shop/classes/exchangeratehandlers/ezecb/ezecbhandler.php" and use EUR as the base currency for auto rates.
You can extend the system by creating custom update handlers for special needs. For example, if you have an extension "myshop" that includes an update handler "mybank", you can put the following lines into an override for the "shop.ini" configuration file:
[ExchangeRatesSettings] ExchangeRatesUpdateHandler=mybank ExtensionDirectories[]=myshop/classes
or
[ExchangeRatesSettings] ExchangeRatesUpdateHandler=mybank RepositoryDirectories[]=extension/myshop/classes/exchangeratehandlers/
These settings will instruct eZ Publish to use the update handler located at"extension/myshop/classes/exchangeratehandlers/mybank/mybankhandler.php"
The following lines can be specified in the "[ECBExchangeRatesSettings]" section of the "shop.ini" configuration file:
ServerName=http://www.ecb.int ServerPort=80 RatesURI=stats/eurofxref/eurofxref-daily.xml
These settings will instruct the eZECB handler to import the currency exchange rates from http://www.ecb.int:80/stats/eurofxref/eurofxref-daily.xml.
This section reveals some helpful tips for those developers who want to create a new exchange rates update handler (only for people who are familiar with PHP). Please note that it is not recommended to modify the eZ publish kernel and thus you implement it as an extension. The following list reveals how you can implement your own handler for rates updating.
$RateList = array( 'currencyCode1' => 'rateValue1', ..... 'currencyCodeN' => 'rateValueN' );
Create a file called "shop.ini.append.php" in the "myextension/settings" directory and add the following lines into it:
[ExchangeRatesSettings] ExchangeRatesUpdateHandler=mybank ExtensionDirectories[]=myextension
This will instruct eZ Publish to use the update handler located at"extension/myextension/exchangeratehandlers/mybank/mybankhandler.php".