I know how to import/export products, orders manually. But is it possible to set up a CRON on my server to do it.
My ERP can export or import files on my server (every hours, or x time a day...) but i want Magento to import the csv file automiticaly.
Is it possible?
regards
If the cron can run PHP code which (or .php file) which it can just knowing how the newsletters work then there is no reason it can’t do that if given the file it needs to run. Just make a PHP with the necessary code in there for exporting the csv or importing and run that cron script.
“Pasting the code that helped me to import products using a cron-
STEP 1: Save the below file as Cron_Import.php on the Magento base folder.
<?php //uncomment when moved to server - to ensure this page is not accessed from anywhere else //if ($_SERVER['REMOTE_ADDR'] !== '<your server ip address') { // die("You are not a cron job!"); //}
$profileId = 3; //put your profile id here $filename = Mage::app()->getRequest()->getParam('files'); // set the filename that is to be imported - file needs to be present in var/import directory if (!isset($filename)) { die("No file has been set!"); } $logFileName= $filename.'.log'; $recordCount = 0;
if ($profileId) { $profile->load($profileId); if (!$profile->getId()) { Mage::getSingleton('adminhtml/session')->addError('The profile you are trying to save no longer exists'); } }
STEP 2: Next step would be to turn on the logging in Admin so that the log file is created. (Navigation: System->Configuration->Developer->Log Settings)
STEP 3: Test this on your SSH login to check if this works on command line. Use the below command
wget -T0 -t1 -O - http://<www.example.com>/Cron_Import.php/?files=3XSEEEE.csv
Note here that the file to be imported is passed as parameter in the URL. Susbtitute ‘3XSEEEE.csv’ with your CSV name.
The completion of the above command should create a log file with name <your CSV file name>.log in the var/log directory. Open this file to see the log messages.
STEP 4: Now setup your Cron with the command mentioned in STEP 4. See if the log file gets created once the cron is activated and runs to completion.
Note: You can make it better by ensuring MAIL TO attribute is set for the Cron so that a mail is sent to inform the completion of the cron.”