This article assumes a certain level of understanding of technical concepts.
- How it works
- Updating from a local file
- Updating from a URL
- The Cron Command
- Creating a recurring Cron Task using CPanel
- Create a recurring Cron Task using the command line
- Partial Imports with Cron
The Total Import PRO module can be run from the command line in an SSH session, or automatically on a Cron Task, provided your webhost allows you to use these functions.
This gives you an extra step of automation over running it manually from the admin of your store. It also allows you to avoid 30 second time limits usually applied by shared webhosts' default PHP settings.
When you go through Steps 1-5, the settings you choose are saved. If you run the module from the command line, either by SSH or a Cron Task, these settings will be used to import your products.
Total Import PRO includes a file called cron_index.php, which will be placed in the admin/ folder of your
store for OpenCart installations, or inside your modules/totalimportpro/ folder for PrestaShop. This is the entry point to the Total Import PRO for SSH or Cron Task. It will bypass the normal security system, however it has its own security so that it can only be run from the command line (not through the webserver). This will prevent unwanted access.
The CLI version only runs Step 1, 3 and 5 of the import.
There are two ways you may wish to update your store automatically: from a feed file on your filesystem that you or another application is uploading regularly, or from a feed file that can be fetched from a URL.
To update from a local file, you will need to upload the file to your store. The Total Import PRO module will search for it in admin/feed.txt for OpenCart, and modules/totalimportpro/feed.txt for PrestaShop. Another process can update this file, and when your Total Import PRO runs next it will pick up the latest feed.txt file.
To update from a URL, simply select the URL option on Step 1, and input the full URL where the feed can be found. If you cannot access the feed through your browser, it is unlikely that the Total Import PRO will be able to either. This is a good test to run in your browser before automating the system. The Total Import
PRO will search for
Use the following command to run the script on a Cron Task or through SSH:
You will need to replace /home/opencart/ with the full path to your installation. If you have multiple saved profiles and you want to run each of them on an automatic schedule, you can set up one cron task per profile to do this. Cron tasks should not be running concurrently as they share crucial resources.
php /home/opencart/admin/cron_index.php profile_name
php /home/prestashop/modules/totalimportpro/cron_index.php profile_name
If your profile name has a space in it, you will need to surround the name with speech marks. e.g profile name should be "profile name"
To set up a recurring Cron Task for your import using Cpanel, you will need to specify how often you want your task to be called. Only one import can be running at a time, so you must allow enough time for your import to finish before scheduling a second import.
To set up a Cron Task which runs once a day at midnight you would use a command like this:
The exact command for setting this up will depend on your host environment, if you have any trouble then you should contact your web host and they will be able to help you set up a cron task.
To create a new cron task you need to edit your crontab file, to edit this run this command:
To add a new crontask which runs once a day at midnight, add a line to the file with this command:
php /home/opencart/admin/cron_index.php my_profile
The last step is to save your crontab file, and you're done!
You can import a partial amount of products through cron by setting a range parameter. See the command below:
php /home/opencart/admin/cron_index.php profile_name 1-100
php /home/prestashop/modules/totalimportpro/cron_index.php profile_name 1-100
This will import the first 100 items from the feed in the profile_name settings profile.