I created this script to scan a folder of images and output the EasyPopulate EP File. There may be an extra linefeed at the end of the file.
The script checks for the existance of an underscore "_" in the filename and skips those files in the Zen Cart extra images model.
URL Parameters are:
folder= folder on server to images
category= category name in ZenCart to add them to.
importer.php?folder=/store/images/jewelry&category=Jewelry
Here is the script:
<?
$sFolder = $_SERVER['DOCUMENT_ROOT'].$_REQUEST['folder'];
$sImagePath = str_replace("/store/images/", "", $_REQUEST['folder']);
$arFields = array(
"v_products_model" => 0,
"v_products_image" => 0,
"v_products_name_1" => 0,
"v_categories_name_1" => $_REQUEST['category'],
"v_products_description_1" => 'Products Description',
"v_products_url_1" => 0,
"v_specials_price" => 0,
"v_specials_date_avail" => 0,
"v_specials_expires_date" => 0,
"v_products_price" => 0,
"v_products_weight" => 0,
"v_date_avail" => 0,
"v_date_added" => 0,
"v_products_quantity" => 1,
"v_manufacturers_name" => 0,
"v_tax_class_title" => 'Taxable Goods',
"v_status" => 1,
"EOREOR" => 0);
$arProducts = array();
$strEcho = '';
foreach($arFields as $key => $value)
$strEcho .= "$key\t";
echo(substr($strEcho,0,strlen($strEcho) - 1)."\n");
$imageNumber = 1;
$rootDir = opendir($sFolder);
while (false !== ($filename = readdir($rootDir))) {
if(strlen($filename) > 2) {
if(strpos($filename, "_") == 0) {
$arFields["v_products_model"] = $_REQUEST["category"].$imageNumber;
$arFields["v_products_image"] = $sImagePath .'/'. $filename;
$arFields["v_products_name_1"] = str_replace("_", " ", substr($filename, 0, strlen($filename) - 4));
$arFields["v_specials_price"] = 30;
$strEcho = '';
foreach($arFields as $key => $value)
$strEcho .= "$value\t";
echo($strEcho."EOREOR\n");
$imageNumber += 1;
}
}
}
?>