Iris96 Posted January 15, 2020 Share Posted January 15, 2020 (edited) Hello everyone, I am interesting to do an auto-update of exchange rate in my shop. Here is where I do the Update of exchange rate manually, at the UPDATE button. Can you tell me how can I do it ? Maybe it is possible with cronjob, but how can I write the script that does the update ? Thank you in advance! Edited March 5, 2020 by Iris96 (see edit history) Link to comment Share on other sites More sharing options...
selectshop.at Posted January 15, 2020 Share Posted January 15, 2020 As each server is using different OS and different configuration, the cronjobs should be created directly from the server via SSH (root servers) or if you are using webhost admin panel (Plesk, cPanel, etc.), then from that admin panel. If you don't know how or don't have samples on your webhost administration panel, ask for support of our provider. Link to comment Share on other sites More sharing options...
Iris96 Posted January 15, 2020 Author Share Posted January 15, 2020 Thank you for your answer! I have access in CPanel. I would like to know how can I write the script that does update the exchange rate. I don't have any information about that, also what kind of programming language should I use. It will be nice if you can advise me. Thank you in advance! Link to comment Share on other sites More sharing options...
selectshop.at Posted January 15, 2020 Share Posted January 15, 2020 It's not a script, but a command line executed on your server. If you don't know how to add cronjobs, please ask your provider for support. Each command line is different from operating system and server settings. As we don't know your server, you will get the best answer from your server admin. If you are on root server, then check via Google for your operating system on how to add cronjobs. How to add cronjob via cPanel: https://documentation.cpanel.net/display/74Docs/Cron+Jobs or https://www.youtube.com/watch?v=Hw0fbM7E80Q 1 Link to comment Share on other sites More sharing options...
Iris96 Posted January 16, 2020 Author Share Posted January 16, 2020 Thank you very much! It worked for me! Link to comment Share on other sites More sharing options...
Frys Posted June 3, 2020 Share Posted June 3, 2020 well that did not answer the question what so ever he pushed you to another site like most of the questions on here i like Prestashop but most people on here like me i would like the helpers to show us a example of the cron job what folders to look in i mean we can all google and find information on it but the real answer should come from here like most of the module addons there is no clear manual to setting up after installing them some of the addons are very expensive and yes they deserve the money the developers are very talented but the manuals are made for people who know php scripts so a like bit more help would be much appreciated instead of here is a website go bloody look 3 Link to comment Share on other sites More sharing options...
JWW Posted September 8, 2020 Share Posted September 8, 2020 I've never done this before and so it took me sometime to figure it out, but I did manage to finally get a cron job setup and working for 1.7.6 that updates the exchange rate once per day. So for anyone else new to this, this is what I found. 1. I discovered that there is a "cron_currency_rates.php" file in the "admin" directory which I used my hosts file manager to find. 2. In my hosts cpanel I created a cron job pointing to this file that runs once per day. I just selected the once per day common option available in my cpanel. 3. It did not work until I added a "secure_key" to the end of the command, i.e. /usr/bin/php /home/USER/domains/DOMAIN/public_html/admin/cron_currency_rates.php secure_key=SECURE KEY GOES HERE. Your exact location will likely be different.There must be a space before "secure_key". 4. I had to figure out how to find my "secure_key" and so I realized that in the "cron_currency_rates.php" there is this code that creates the key and compares it against the key passed in during step 3: $secureKey = md5(_COOKIE_KEY_.Configuration::get('PS_SHOP_NAME')); 5. First, I put my store in maintenance mode. Then, to find this key I created this code: print_r("secure_key="); print_r(md5(_COOKIE_KEY_.Configuration::get('PS_SHOP_NAME')) ); Then I put it in the "index.php" file in the "admin" directory just after the line: require _PS_ADMIN_DIR_.'/../config/config.inc.php'; This displayed the "secure_key" just above the header on my dashboard 6. I copied the key and replaced the "SECURE KEY GOES HERE" in step 3. Then I went back to the "index.php" and DELETED the code in step 5. I now have a working cron job that updates the exchange rate once per day. Hope this helps someone. 2 1 Link to comment Share on other sites More sharing options...
jhugues Posted January 19, 2021 Share Posted January 19, 2021 Thank You JWW it worked for me. Link to comment Share on other sites More sharing options...
blindwarrior17 Posted January 19, 2021 Share Posted January 19, 2021 Awesome, this was a big help! Link to comment Share on other sites More sharing options...
Mediacom87 Posted February 25, 2021 Share Posted February 25, 2021 Hi, If you want to know quickly and simply the exchange rate update url of your PrestaShop 1.7 store, I made available to the community a free module. I hope it will be helpful. Link to comment Share on other sites More sharing options...
GoPure Kratom Posted March 9, 2021 Share Posted March 9, 2021 Thanks for @JWW for instructions and @Mediacom87 for helping to figure out the secure key. I've created cron job to run: /usr/local/bin/php /home/xxxxxx/public_html/admin_dir/cron_currency_rates.php secure_key=xxxxxxxxxxxxxxxxxxxxxxx However, when I try to run it in SSH, it gives some errors for includes. I solved this by changing the cron command to: cd /home/xxxxxx/public_html/admin_dir/; /usr/local/bin/php cron_currency_rates.php secure_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx This seems to work on the command line, but is there a cleaner way to do this...? Then again, when it's not broken, don't fix it... 🤷♂️ Link to comment Share on other sites More sharing options...
Danny Posted March 3, 2022 Share Posted March 3, 2022 Hi, i added the module from @Mediacom87 (many thanks), i set the cronjob in my Cpanel and it does not update the currency. I tought maybe the syntax is not correct, sent the command to my provider and they says it works (they tested live, no errors). Any idea what it could be? sp-php /home/main_dir/public_html/back_office/cron_currency_rates.php secure_key=xxx i can give it a try like @GoPure Kratom but since i dont have ssh access i am not sure that his way will work Link to comment Share on other sites More sharing options...
Danny Posted March 7, 2022 Share Posted March 7, 2022 hi all i solved the problem recalling the entire url the module Mediacom87 gently provided, i used the Cron Job with a wget Link to comment Share on other sites More sharing options...
ficusonlinestore Posted March 22, 2022 Share Posted March 22, 2022 How to check $secureKey; Added "echo $secureKey" in the below line. if (isset($_GET['secure_key'])) { $secureKey = md5(_COOKIE_KEY_.Configuration::get('PS_SHOP_NAME')); echo $secureKey; if (!empty($secureKey) && $secureKey === $_GET['secure_key']) { $shop_ids = Shop::getCompleteListOfShopsID(); foreach ($shop_ids as $shop_id) { Shop::setContext(Shop::CONTEXT_SHOP, (int)$shop_id); Currency::refreshCurrencies(); } } } then execute the following command. in here, the below secure_key is anything of available you like. # php /var/www/html/admin/cron_currency_rates.php secure_key=aaaaa displayed the correct secure key. Finally, fixed the command for updating the currency rates. # php /var/www/html/admin/cron_currency_rates.php secure_key=displayed_the_correct_secure_key Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now