FINALLY I got this up and running!
I have spent so many hours on this supposedly simple task!... So I thought I should post some SOLUTIONS to some of the issues I have struggled with. As always, answers are more or less obvious, and have been enlightened before…
With a possibility to be totally out sailing, this works for me (so far):
currency_update.php
The versions after 2006 are using “ecb” for feed. Earlier versions are using “oanda” and ”xe” as the manual update in your Admin.
The mod, consisting of a single file, could be placed anywhere, but has to be edited to work:
In the first line of script (about row 14-17) “DEFINE” You should set the path FROM the file to the root of your store.
E.g. If you put the file directly onto your store root, this should only be a slash “/”. If you put it in “includes” it should be “./” and so on. (Path upwards in hierarchy)
In the next two lines “require_once” I had to set the FULL path to the two files: “configure.php” and “database_tables.php”. On my server I have named my store root “shop”, and my path is roughly: “/home/t/troll/www/shop/includes/configure.php” and “/home/t/troll/www/shop/includes/database_tables.php”
Cron job
In your command shell write “crontab –l” to list your crontab, and “crontab –e” to edit it. To edit in “VI” use “i” to insert, and “Esc : w q” to write to file and quit VI.
Your crontab has to include the full path to your “currency_update.php” file.
In my case I also had to include full path to php command. My cron that runs for every 6’th hour look like this:
* 0-23/6 * * * /usr/local/bin/php /home/t/troll/www/shop/currency_update.php
(Beware of the space between the php command and the path to the currency_update.php file.)
The cron setup paremeters are:
.---------------- minute (0 - 59)
| .------------- hour (0 - 23)
| | .---------- day of month (1 - 31)
| | | .------- month (1 - 12) OR jan,feb,mar,apr ...
| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * command to be executed
For example, to run a cron job once a day at midnight set up: 0 0 * * * /path/to/php /path/to/file.php
To test your cron job you could set the job for a short interval. E.g. Setting it: 0-59/2 * * * * /path….
Will run the job every second minute. It’s then easy to check if your currency rate changing just by changing the “Currency Conversion Ratio” in your “Admin > Configuration > My Store”, and wait for two minutes. (Assuming that one works as it should…)
If you set the parameters wrong in your crontab, it should output a message when you save.
If you for example have got the paths wrong, and the job is NOT working properly, it outputs a mail with the error. (Just write “mail” in your command shell.)
Btw. You can check what services your host provides by simply making an “info.php” file, and add the code: <? phpinfo(); ?> into it. Then just open the “info.php” file in your browser.)
Hope this could be of some help for somebody!
Troll![]()
Bookmarks