Post by rm113 » Wed Aug 30, 2017 7:58 pm

Hi there! I need to create a cron job script to be written to update products I'm selling from my dropshipper.

I am using Opencart 2.3. I am carrying 5000+ products from a dropshipper and I'd like to create a script you to update stock every day.

Would it be possible to get help me with this and just explain in plain language (I'm a newbie to this) the script as it would apply to me along with where this file gets implemented in Opencart (i.e. public_html?).

Any help anyone can provide would be most appreciated ASAP.

Thanks.

New member

Posts

Joined
Sat May 20, 2017 6:17 pm

Post by MrPhil » Sat Sep 02, 2017 2:49 am

Do you already have a PHP script (either standalone or built into OC) that can read in, say, a CSV or XML file and directly update your store database? That's going to be 95% of the effort, so make sure you have that ready first. Make sure it's robust enough that a missing or bad CSV file isn't going to bring down your store. I'm sure someone has done this work before, so you may not have to do much work to get going. Will the data file (CSV) be automatically uploaded to the server, or is it a manual operation? If it's manual, there may not be much point in doing it as a cron job. You might be able to use something like cURL to access the data file on another machine, such as your PC.

Then, installing, configuring, and running this script is a minor matter. You can put it anywhere, even outside of public_html, as you won't be running it from the browser (although, you can put it somewhere under public_html if you think you might sometimes want to run it manually). If you do have it under public_html, and it's not password-protected, be sure to give it (or the directory it's in) an unguessable name to minimize the chances of someone else maliciously running it.

Keep in mind that your cron job will have to specify "php" explicitly, and the full path of the file (it's running on the server's OS command line). Don't count on the environment (path and other settings) being the same as on the server, since you're running outside of that environment -- give all paths, etc. explicitly. "cron" is just a way to regularly schedule programs to be run on the server's command line -- there's nothing magical about it. It's a batch (non-interactive) run, and messages get mailed to you.

Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm
Who is online

Users browsing this forum: No registered users and 15 guests