
Originally Posted by
Ryk
As one tends to get a bit of tunnel vision after 3 years of Zen Carting, I have no idea whether this sort of thing is even possible....
Receive excel file
convert excel file to fit EasyPopulate excel layout
ftp EP file to website
insert into ZC database
...all without human intervention.
Is this doable?
I have a partial solution which I've not tested.
You can save an excel spreadsheet in CSV format and use, the Easy Populate CSV add on, available here:
http://www.zen-cart.com/index.php?ma...oducts_id=1240
Ftp the file to /tempEP (the default import directory).
Let's say the file is called import_me.csv
You might be able to automate the above with a batch script.
Then create a script to be called by cron every five minutes say.
The script must first authenticate itself.
see:
http://www.zen-cart.com/forum/showthread.php?t=114279
The script then sets the filename variable to import and runs the easypopulate code.
To authenticate we need to override init_admin_auth.php.
So copy
admin/includes/init_includes/init_admin_auth.php
to
admin/includes/init_includes/overrides/init_admin_auth.php
and add
"""
// to allow cron jobs set CRON_ADMIN_USER_ID
if ($_SERVER['REMOTE_ADDR'] == $_SERVER['SERVER_ADDR']) {
if (!isset($_SESSION['admin_id']) && defined('CRON_ADMIN_USER_ID') && CRON_ADMIN_USER_ID != '') {
$_SESSION['admin_id'] = CRON_ADMIN_USER_ID;
}
}
"""
to just after
"""
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
"""
Then we write the script for cron.
Create a file /admin/cron1.php:
<?php
define('CRON_ADMIN_USER_ID', '999');
require ('includes/application_top.php');
$_POST['localfile'] = "import_me.csv";
require ('easypopulate.php');
?>
Then set up the cron job to call the script eg:
Please note I haven't thoroughly tested this.