This will download a datafeed to your server from the given FTP account. This only supports CSV datafeeds and requires a minor tweak to accomodate any other type of datafeed. It also requires that you have wget installed on your server. The user executing this script needs to have write access to the "datafeeds" folder.
This can be used in conjunction with my PHP gunzip, unzip File Extractor
Note: "wget -P db" means to put the file in the /db directory. You'll need to create it or change that parameter to match your system.
<?php
$login = 'login';
$password = 'password';
$server = 'ftp.merchant.com';
$datafeed_file = "datafeed.csv";
unlink("datafeeds/$datafeed_file");
$path = "wget -P db ftp://$login:$password@$server/datafeed/$datafeed_file";
`$path`;
$datafeed = "datafeeds/$datafeed_file";
$fp = fopen($datafeed, 'r');
while($data = fgetcsv($fp, 3000))
{
$sku = $data[0];
$name = addslashes(preg_replace("/"/", '', $data[1]));
// And so on...
}
?>