To create a support ticket, start a search

Fetching a CSV file on a distant URL to run on a CRON task

The CSV import file used to update your products via a CRON task is located on a distant URL.

Below is the data you will need to add to the CRON php configuration file to apply the process.

First of all, you need to set up the configuration file on your server. Refer to this article for the detailed procedure.

To then fetch the CSV file on a distant URL, add the following lines to the php configuration file, on the 4th line, just before // CSV filename:

 

$data = file_get_contents('http://Distant/File/URL.extension');
if($data == false) {
    die("Error: Unable to retrieve data. Check the url of your remote file and its accessibility.");
}
if(empty($data)) {
    die("Error: Empty data");
}
file_put_contents('../../import/your_csv_file.csv',$data);
unset($data);

 

The name of your local CSV file will need to be the one indicated in this setting:

$_GET['filename'] = 'file_to_import.csv'; 

 


 



Related articles