Jump to content

[Solved] Create a Cronjob to auto-update Exchange rate


Recommended Posts

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!

image.thumb.png.4be0b3d64717980a79fed687753f315a.png

Edited by Iris96 (see edit history)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 2 months later...

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

  • Like 1

Share this post


Link to post
Share on other sites
  • 3 months later...

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.

  • Like 1

Share this post


Link to post
Share on other sites
  • 4 months later...
  • 1 month later...

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.

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More