To create a support ticket, start a search

Automating your imports with a CRON task


mars_article_03.jpgCRON is a time-based job scheduler in Unix-like computer operating systems. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates

It is indeed interesting to get the system to run recurent and repetitive tasks automatically instead of involving a manual intervention by the user.

Here is how you can make your life easier by automating your imports using a CRON task, allowing you to create and/or modify your products.

 

  1. Configure your CSV import once to check that it works when ran manually 
    A common configuration would be to identify products by their reference and to replace their properties 
  2. Download the attached file 
  3. Unzip the file and rename it cron_import_YYY.php (choose an recognisable name) 
  4. Edit the file to configure it 
     

The first lines allow to modify the configuration:

// Cron task name
if (!isset($_GET['name']))
$_GET['name'] = 'My task 1'; 

// CSV filename, all options must be set and tested in Store Commander
if (!isset($_GET['filename']))
$_GET['filename'] = 'file_to_import.csv'; 

// Do you need to delete the working file (TODO.csv) ?
if (!isset($_GET['deletetodofile']))
$_GET['deletetodofile'] = 0;

// Update only old products? This option will skip products recently updated 
// (in minutes: set this option to 120 in order to update only products updated more than 2 hours ago)
if (!isset($_GET['olderthan']))
$_GET['olderthan'] = 0;

// internal security key to use in CRON ( you should call /modules/storecommander/XXXX/SC/cron_import_YYY.php?key=4hfsz65j4e68h4reh )
$localkey = '4hfsz65j4e68h4reh'; 

// the import result is sent to this email address
$emailaddress = 'info@yourwebsite.com';

// email title
$emailtitle = '[CRON] Import SC';

// website url for the link inluded in the email.
$websiteURL = 'http://www.yourwebsite.com';


** Do not modify the following lines **
 

Important note: Do not use the security key above as it is used as an exemple for this article.

Then, add the file on your server in directory:

/modules/storecommander/XXX/SC/cron_import_YYY.php


You will then simply call this URL with the CRON task on your server:

/modules/storecommander/XXX/SC/cron_import_YYY.php?key=4hfsz65j4e68h4reh

 

/XXX/ corresponds to a serie of letters and digit corresponding to your installation.

 

  If Store Commander is installed in the /adminXXX/ directory, it is recommended to move onto the /modules/ version. Please refer to this article for detailed instructions.
 

 


Download our dedicated Guides to learn how to manage your shop at lightning speed with Store Commander.



Related articles