How to Auto-Update the Exchange Rates with Cron Job
As a professional e-Commerce solution, PrestaShop does support multi-currency on selling products certainly. The related setting can be found in backoffice in International
→ Localization
Don’t know how to set up currencies? Check out our video!
We can find a option on bottom like the below picture, which enable to update the exchange rate periodically. However, you can see that the switch is greyed out with a text saying to let you install the cronjobs module.
It used to be a cron job module available in the add-on marketplace, which able user to set cron job with this module. However, this module was removed, as it was not working reliably, while it is actually hard to cover different OS with only one module. Therefore, the best practice would always be setting it directly on the server, or via the hosting.
But how do we set this?
No idea how to set up Cron Job? Check out our article!
We are using curl / wget to browse a PHP file inside the admin folder, so you need:
- Figure out the complete URL which link to that PHP file
A secure key is also required to access the function by passing to the url and you will need the below to get the key:
- COOKIE_KEY
- Shop Name
- MD5 Generator
- The backoffice folder is named
admin2021
- We are updating the exchange at 6am per day
- The domain of the website is:
http://shop.genkiware.com/
The PHP file is named cron_currency_rates.php
inside the admin folder. Therefore, in this exmaple, the URL to the file will be:
http://shop.genkiware.com/admin2021/cron_currency_rates.php
COOKIE_KEY
- This is a 56-char string and unique for every shop, which could be found easily in app/config/parameters.php
We are using this as example:HaNS1NpRvOFSmcOuaxu1OAhA7JYzAi5BHqHs3B4SrfL7E3LgjBWI7O2x
Shop Name
There are 2 ways to find it:
- Go to
Shop Parameters
→Contact
. Look for theStores
tab, then get the shop name on the bottom “Contact Detail”
- Run the following SQL on your database:
SELECT `value` FROM `ps_configuration` WHERE `name` = 'PS_SHOP_NAME'
MD5 Generator
- The key is generated by MD5 digesting after joining the COOKIE KEY and the shop name. There are lots of MD5 tools on the internet and below is one of the example:
https://codebeautify.org/md5-hash-generator
Process
- Join the COOKIE KEY and shop name:
HaNS1NpRvOFSmcOuaxu1OAhA7JYzAi5BHqHs3B4SrfL7E3LgjBWI7O2xGenkiStore
- Digest with MD5 you will get the secure key:
dd8de15a41ed5815785a08f1256dbd8c
As we are updating it 6am per day, so the period should write 0 6 * * *
The complete URL will be http://shop.genkiware.com/admin2021/cron_currency_rates.php?secure_key=dd8de15a41ed5815785a08f1256dbd8c
Finally, the full sentence to be written in crontab -e on the server would be:
0 6 * * * curl "http://shop.genkiware.com/admin2021/cron_currency_rates.php?secure_key=dd8de15a41ed5815785a08f1256dbd8c"
And…Done! Your shop would now update the exchange rate automatically at 6am per day, Yay!
Related Post
ManyChat Keywords Setup
Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/genkiware/wp-content/themes/optima/single.php on line 185
After the basic chatbot message is set, you may also…
How to start Omnichannel Retail Strategy
Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/genkiware/wp-content/themes/optima/single.php on line 185
A retail shop with only one single-channel is already traditional.…