コード例 #1
0
 public function updateIndexes()
 {
     //make sure we are not in session
     if (session_id() !== "") {
         session_write_close();
     }
     $magdir = Magmi_Config::getInstance()->getMagentoDir();
     $cl = $this->getParam("REINDEX:phpcli") . " {$magdir}/shell/indexer.php";
     $idxlstr = $this->getParam("REINDEX:indexes", "");
     $idxlist = explode(",", $idxlstr);
     if (count($idxlist) == 0) {
         $this->log("No indexes selected , skipping reindexing...", "warning");
         return true;
     }
     foreach ($idxlist as $idx) {
         $tstart = microtime(true);
         $this->log("Reindexing {$idx}....", "info");
         $out = shell_exec("{$cl} --reindex {$idx}");
         $this->log($out, "info");
         $tend = microtime(true);
         $this->log("done in " . round($tend - $tstart, 2) . " secs", "info");
         if (Magmi_StateManager::getState() == "canceled") {
             exit;
         }
         flush();
     }
 }
コード例 #2
0
 public function getMagentoBaseDir()
 {
     $magmi_conf = Magmi_Config::getInstance();
     $magmi_conf->load();
     $mbd = $magmi_conf->get("MAGENTO", "basedir");
     unset($magmi_conf);
     return $mbd;
 }
コード例 #3
0
 public function getScanDir($resolve = true)
 {
     $scandir = $this->getParam("CSV:basedir", "var/import");
     if (!isabspath($scandir)) {
         $scandir = abspath($scandir, Magmi_Config::getInstance()->getMagentoDir(), $resolve);
     }
     return $scandir;
 }
コード例 #4
0
ファイル: utils.php プロジェクト: vikaskalra/magmi-git
function getSessionConfig()
{
    $conf = Magmi_Config::getInstance();
    if (isset($_SESSION['MAGMI_CONFIG_FILE'])) {
        $conf->load($_SESSION['MAGMI_CONFIG_FILE']);
    } else {
        $conf->load();
    }
    return $conf;
}
コード例 #5
0
 public function testExistingProfileFromCustomFile()
 {
     $conf = Magmi_Config::getInstance();
     $conf->load(__DIR__ . "/test.ini");
     $dp = Magmi_DataPumpFactory::getDataPumpInstance("productimport");
     $dp->beginImportSession("xmlimport", "create");
     $ep = $dp->getEngine()->getPluginClasses();
     $this->assertContains('CategoryImporter', $ep['itemprocessors']);
     $this->assertContains('ImageAttributeItemProcessor', $ep['itemprocessors']);
     $this->assertContains('ItemIndexer', $ep['itemprocessors']);
     $this->assertContains('GenericMapperProcessor', $ep['itemprocessors']);
     $dp->endImportSession();
 }
コード例 #6
0
ファイル: magmi_engine.php プロジェクト: vstorm83/ausport
 public final function initialize($params = array())
 {
     try {
         $this->_conf = Magmi_Config::getInstance();
         $this->_conf->load();
         $this->tprefix = $this->_conf->get("DATABASE", "table_prefix");
         $this->_excid = 0;
         $this->_initialized = true;
         $this->_exceptions = array();
     } catch (Exception $e) {
         die("Error initializing Engine:{$this->_conf->getConfigFilename()} \n" . $e->getMessage());
     }
 }
コード例 #7
0
 public function testCatMultiRoot()
 {
     $conf = Magmi_Config::getInstance();
     $conf->load(__DIR__ . "/test.ini");
     $dp = Magmi_DataPumpFactory::getDataPumpInstance("productimport");
     $reader = new Magmi_CSVReader();
     $reader->initialize(array("CSV:filename" => __DIR__ . '/categories/category_multiroot.csv'));
     $reader->openCSV();
     $reader->getColumnNames();
     $dp->beginImportSession("catconf", "create", new FileLogger(__DIR__ . '/test.log'));
     while ($item = $reader->getNextRecord()) {
         $dp->ingest($item);
     }
     $dp->endImportSession();
     $reader->closeCSV();
 }
コード例 #8
0
 public function checkPluginVersion()
 {
     $pv = $this->_raproxy->getVersion();
     if ($pv == '0.0.0') {
         $this->log("Remote Agent Not found at " . $this->_raproxy->getRemoteAgentUrl(), "startup");
     } else {
         $this->log("Remote Agent v{$pv} found at " . $this->_raproxy->getRemoteAgentUrl(), "startup");
     }
     $cv = Magmi_RemoteAgent::getStaticVersion();
     if ($pv < $cv) {
         $this->log("Deploying latest v{$cv}");
         $ok = $this->deployPlugin(Magmi_Config::getInstance()->getMagentoDir());
         if ($ok) {
             $cpv = $this->_raproxy->getVersion();
             $this->log("Remote Agent v{$cpv} deployed at " . $this->_raproxy->getRemoteAgentUrl(), "startup");
         }
     }
     $this->_active = true;
 }
コード例 #9
0
 public function processItemBeforeId(&$item, $params = null)
 {
     // get list of trimmable columns
     $tc = $this->getTrimmableCols($item);
     foreach ($tc as $col => $mode) {
         // for select, just trim value
         if ($mode == "select") {
             $item[$col] = trim($item[$col]);
         } else {
             $sep = Magmi_Config::getInstance()->get("GLOBAL", "mutiselect_sep", ",");
             $vt = explode($sep, $item[$col]);
             foreach ($vt as &$v) {
                 $v = trim($v);
             }
             $item[$col] = implode($sep, $vt);
             unset($vt);
         }
     }
     return true;
 }
コード例 #10
0
 public function __construct($user, $pass)
 {
     parent::__construct();
     $this->user = $user;
     $this->pass = $pass;
     $this->_conf = Magmi_Config::getInstance();
     $this->_conf->load();
     $host = $this->_conf->get("DATABASE", "host", "localhost");
     $dbname = $this->_conf->get("DATABASE", "dbname", "magento");
     $user = $this->_conf->get("DATABASE", "user");
     $pass = $this->_conf->get("DATABASE", "password");
     $port = $this->_conf->get("DATABASE", "port", "3306");
     $socket = $this->_conf->get("DATABASE", "unix_socket", false);
     try {
         $this->initDb($host, $dbname, $user, $pass, $port, $socket);
         $this->tablename = $this->_conf->get("DATABASE", "table_prefix") . "admin_user";
         $this->_hasDB = true;
     } catch (Exception $e) {
         $this->_hasDB = false;
     }
 }
コード例 #11
0
 public function getRemoteFile($url)
 {
     $fg = RemoteFileGetterFactory::getFGInstance();
     if ($this->getParam("CSV:remoteauth", false) == true) {
         $user = $this->getParam("CSV:remoteuser");
         $pass = $this->getParam("CSV:remotepass");
         $fg->setCredentials($user, $pass);
     }
     $cookies = $this->getParam("CSV:remotecookie");
     if ($cookies) {
         $fg->setCookie($cookies);
     }
     $this->log("Fetching CSV: {$url}", "startup");
     // output filename (current dir+remote filename)
     $csvdldir = dirname(__FILE__) . "/downloads";
     if (!file_exists($csvdldir)) {
         @mkdir($csvdldir);
         @chmod($csvdldir, Magmi_Config::getInstance()->getDirMask());
     }
     $outname = $csvdldir . "/" . basename($url);
     $ext = substr(strrchr($outname, '.'), 1);
     if ($ext != "txt" && $ext != "csv") {
         $outname = $outname . ".csv";
     }
     // open file for writing
     if (file_exists($outname)) {
         if ($this->getParam("CSV:forcedl", false) == true) {
             unlink($outname);
         } else {
             return $outname;
         }
     }
     $fg->copyRemoteFile($url, $outname);
     // return the csv filename
     return $outname;
 }
コード例 #12
0
ファイル: magmi.cli.php プロジェクト: bjoern-tantau/magmi-git
{
    if (!isset($options["engine"])) {
        $options["engine"] = "magmi_productimportengine:Magmi_ProductImportEngine";
    }
    $enginst = getClassInstance($options["engine"], dirname(dirname(__FILE__)) . "/engines");
    return $enginst;
}
// Building option list from command line
$options = buildOptions($argv);
// Getting engine
$importer = getEngineInstance($options);
if (isset($importer)) {
    $inifile = isset($options['config']) ? $options['config'] : null;
    if (isset($inifile)) {
        require_once 'magmi_config.php';
        $conf = Magmi_Config::getInstance();
        $conf->load($options['config']);
    }
    // if logger set, use it or use FileLogger by default
    $loggerclass = isset($options['logger']) ? $options['logger'] : "FileLogger";
    $importer->setLogger(new $loggerclass());
    // a chain is a multiple profile run with the following syntax
    // [profilename]:[modename],[profilename]:[modename]
    // if no workflow chain is defined, create a new one
    if (!isset($options["chain"])) {
        $options["chain"] = isset($options["profile"]) ? $options["profile"] : "";
        $options["chain"] .= isset($options["mode"]) ? ":" . $options["mode"] : "";
    }
    // parsing the workflow chain
    $pdefs = explode(",", $options["chain"]);
    // for each import in the workflow
コード例 #13
0
 public function getRemoteFile($url, $creds = null, $authmode = null, $cookies = null)
 {
     $ch = curl_init($url);
     $this->log("Fetching CSV: {$url}", "startup");
     //output filename (current dir+remote filename)
     $csvdldir = dirname(__FILE__) . "/downloads";
     if (!file_exists($csvdldir)) {
         @mkdir($csvdldir);
         @chmod($csvdldir, Magmi_Config::getInstance()->getDirMask());
     }
     $outname = $csvdldir . "/" . basename($url);
     $ext = substr(strrchr($outname, '.'), 1);
     if ($ext != ".txt" && $ext != ".csv") {
         $outname = $outname . ".csv";
     }
     //open file for writing
     if (file_exists($outname)) {
         unlink($outname);
     }
     $fp = fopen($outname, "w");
     if ($fp == false) {
         throw new Exception("Cannot write file:{$outname}");
     }
     if (substr($url, 0, 4) == "http") {
         $lookup = 1;
         $lookup_opts = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => true, CURLOPT_NOBODY => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_FILETIME => true, CURLOPT_CUSTOMREQUEST => "HEAD");
         $dl_opts = array(CURLOPT_FILE => $fp, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HEADER => false, CURLOPT_NOBODY => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_UNRESTRICTED_AUTH => true, CURLOPT_HTTPHEADER => array('Expect:'));
     } else {
         if (substr($url, 0, 3) == "ftp") {
             $lookup = 0;
             $dl_opts = array(CURLOPT_FILE => $fp);
         }
     }
     if ($creds != "") {
         if ($lookup != 0) {
             if (substr($url, 0, 4) == "http") {
                 $lookup_opts[CURLOPT_HTTPAUTH] = CURLAUTH_ANY;
                 $lookup_opts[CURLOPT_UNRESTRICTED_AUTH] = true;
             }
             $lookup_opts[CURLOPT_USERPWD] = "{$creds}";
         }
         if (substr($url, 0, 4) == "http") {
             $dl_opts[CURLOPT_HTTPAUTH] = CURLAUTH_ANY;
             $dl_opts[CURLOPT_UNRESTRICTED_AUTH] = true;
         }
         $dl_opts[CURLOPT_USERPWD] = "{$creds}";
     }
     if ($cookies) {
         if ($lookup != 0) {
             if (substr($url, 0, 4) == "http") {
                 $lookup_opts[CURLOPT_COOKIE] = $cookies;
             }
         }
         if (substr($url, 0, 4) == "http") {
             $dl_opts[CURLOPT_COOKIE] = $cookies;
         }
     }
     if ($lookup) {
         //lookup , using HEAD request
         $ok = curl_setopt_array($ch, $lookup_opts);
         $res = curl_exec($ch);
         if ($res !== false) {
             $lm = curl_getinfo($ch);
             if (curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200) {
                 $resp = explode("\n\r\n", $res);
                 $this->log("http header:<pre>" . $resp[0] . "</pre>", "error");
                 throw new Exception("Cannot fetch {$url}");
             }
         } else {
             $lm = curl_getinfo($ch);
             throw new Exception("Cannot fetch {$url}");
         }
     }
     $res = array("should_dl" => true, "reason" => "");
     if ($res["should_dl"]) {
         //clear url options
         $ok = curl_setopt_array($ch, array());
         //Download the file , force expect to nothing to avoid buffer save problem
         curl_setopt_array($ch, $dl_opts);
         curl_exec($ch);
         if (curl_error($ch) != "") {
             $this->log(curl_error($ch), "error");
             throw new Exception("Cannot fetch {$url}");
         } else {
             $lm = curl_getinfo($ch);
             $this->log("CSV Fetched in " . $lm['total_time'] . "secs", "startup");
         }
         curl_close($ch);
         fclose($fp);
     } else {
         curl_close($ch);
         //bad file or bad hour, no download this time
         $this->log("No dowload , " . $res["reason"], "info");
     }
     //return the csv filename
     return $outname;
 }
コード例 #14
0
ファイル: ImportSuite1Test.php プロジェクト: GeekAb/Crawlers
 public function testGrouped()
 {
     $conf = Magmi_Config::getInstance();
     $conf->load(__DIR__ . "/test.ini");
     $dp = Magmi_DataPumpFactory::getDataPumpInstance("productimport");
     $dp->beginImportSession("grouped", "create", new FileLogger(__DIR__ . "/log_" . __FUNCTION__ . ".txt"));
     //import 10 simples
     for ($i = 0; $i < 10; $i++) {
         $item = array("sku" => "SG" . str_pad($i, 4, "0", STR_PAD_LEFT) . "_item", "name" => "simple item {$i}", "description" => "test description", "short_description" => "test short desc", "type" => "simple", "attribute_set" => "apparel", "weight" => 0, "price" => 10, "qty" => 1, "visibility" => "1");
         $dp->ingest($item);
         unset($item);
     }
     //import configurable
     $item = array("sku" => "G000", "name" => "grouped item 0", "description" => "config desc", "short_description" => "config short", "type" => "grouped", "is_in_stock" => 1, "attribute_set" => "apparel", "configurable_attributes" => "color", "grouped_skus" => "SG0001_item,SG0003_item,SG0005_item", "category_ids" => "2", "visibility" => "4");
     $dp->ingest($item);
     $dp->endImportSession();
 }
コード例 #15
0
 /**
  * copy image file from source directory to
  * product media directory
  *
  * @param $imgfile :
  *            name of image file name in source directory
  * @return : name of image file name relative to magento catalog media dir,including leading
  *         directories made of first char & second char of image file name.
  */
 public function copyImageFile($imgfile, &$item, $extra)
 {
     if ($imgfile == "__NULL__" || $imgfile == null) {
         return false;
     }
     // check for source image in error
     if ($this->isErrorImage($imgfile)) {
         if ($this->_newitem) {
             $this->fillErrorAttributes($item);
         }
         return false;
     }
     //handle remote root per image
     if (!is_remote_path($imgfile)) {
         if ($this->_remoteroot != "") {
             $imgfile = $this->_remoteroot . str_replace("//", "/", "/{$imgfile}");
         }
     }
     //handle amazon specific
     if (is_remote_path($imgfile)) {
         // Amazon images patch , remove SLXXXX part
         if (preg_match('|amazon\\..*?/images/I|', $imgfile)) {
             $pattern = '/\\bSL[0-9]+\\./i';
             $imgfile = preg_replace($pattern, '', $imgfile);
         }
     }
     $source = $this->findImageFile($imgfile);
     if ($source == false) {
         $this->log("{$imgfile} cannot be found in images path", "warning");
         // last image in error,add it to error cache
         $this->setErrorImg($imgfile);
         return false;
     }
     $imgfile = $source;
     $checkexist = $this->getParam("IMG:existingonly") == "yes";
     $curlh = false;
     $bimgfile = $this->getTargetName($imgfile, $item, $extra);
     // source file exists
     $i1 = $bimgfile[0];
     $i2 = $bimgfile[1];
     // magento image value (relative to media catalog)
     $impath = "/{$i1}/{$i2}/{$bimgfile}";
     // target directory;
     $l2d = "media/catalog/product/{$i1}/{$i2}";
     // test for existence
     $targetpath = "{$l2d}/{$bimgfile}";
     /* test for same image (without problem) */
     if ($impath == $this->_lastimage) {
         return $impath;
     }
     /* test if imagefile comes from export */
     if (!$this->_mdh->file_exists($targetpath) || $this->getParam("IMG:writemode") == "override") {
         // if we already had problems with this target,assume we'll get others.
         if ($this->isErrorImage($impath)) {
             return false;
         }
         /* try to recursively create target dir */
         if (!$this->_mdh->file_exists($l2d)) {
             $tst = $this->_mdh->mkdir($l2d, Magmi_Config::getInstance()->getDirMask(), true);
             if (!$tst) {
                 // if we had problem creating target directory,add target to error cache
                 $errors = $this->_mdh->getLastError();
                 $this->log("error creating {$l2d}: {$errors["type"]},{$errors["message"]}", "warning");
                 unset($errors);
                 $this->setErrorImg($impath);
                 return false;
             }
         }
         if (!$this->saveImage($imgfile, $targetpath)) {
             $errors = $this->_mdh->getLastError();
             $this->fillErrorAttributes($item);
             $this->log("error copying {$l2d}/{$bimgfile} : {$errors["type"]},{$errors["message"]}", "warning");
             unset($errors);
             $this->setErrorImg($impath);
             return false;
         } else {
             @$this->_mdh->chmod("{$l2d}/{$bimgfile}", Magmi_Config::getInstance()->getFileMask());
             if ($this->getParam("IMG:storeindb", "no") == "yes") {
                 /* create target dirs if they don't exist */
                 $dir_table = $this->tablename('core_directory_storage');
                 // get "catalog/product" path ID
                 $sql = "SELECT directory_id from {$dir_table} where name='product' and path='catalog'";
                 $parent_id = $this->selectone($sql, null, 'directory_id');
                 // check if i1 dir exists
                 $i1_dir = "catalog/product/{$i1}";
                 $sql = "SELECT directory_id FROM {$dir_table} WHERE name=? and parent_id=?";
                 $i1_dir_id = $this->selectone($sql, array($i1, $parent_id), 'directory_id');
                 // insert if it doesn't exist
                 if ($i1_dir_id == null) {
                     $sql = "INSERT INTO {$dir_table} (name, path, upload_time, parent_id)\n                                    VALUES (?, 'catalog/product', NOW(), ?);";
                     $i1_dir_id = $this->insert($sql, array($i1, $parent_id));
                 }
                 // check if i2 dir exists
                 $i2_dir = "{$i1_dir}/{$i2}";
                 $sql = "SELECT directory_id FROM {$dir_table} WHERE name=? and parent_id=?";
                 $i2_dir_id = $this->selectone($sql, array($i2, $i1_dir_id), 'directory_id');
                 // insert second level if it doesn't exist
                 if ($i2_dir_id == null) {
                     $sql = "INSERT INTO {$dir_table} (name, path, upload_time, parent_id)\n                                    VALUES (?, ?, NOW(), ?);";
                     $i2_dir_id = $this->insert($sql, array($i2, $i1_dir, $i1_dir_id));
                 }
                 /* insert the image */
                 $media_table = $this->tablename('core_file_storage');
                 $sql = "SELECT file_id FROM {$media_table} WHERE filename=? and directory_id=?";
                 $existing_file_id = $this->selectone($sql, array($bimgfile, $i2_dir_id), 'file_id');
                 if ($existing_file_id == null || $this->getParam("IMG:writemode") == "override") {
                     $image_path = $this->magdir . '/' . $targetpath;
                     $image_content = file_get_contents($image_path);
                     $sql = "INSERT INTO {$media_table} (content, upload_time, filename, directory_id, directory)\n                                    VALUES (?, NOW(), ?, ?, ?)\n                                    ON DUPLICATE KEY UPDATE content=VALUES(content), upload_time=VALUES(upload_time);";
                     $file_id = $this->insert($sql, array($image_content, $bimgfile, $i2_dir_id, $i2_dir));
                 }
             }
         }
     }
     $this->_lastimage = $impath;
     /* return image file name relative to media dir (with leading / ) */
     return $impath;
 }
コード例 #16
0
 /**
  * attribute handler for Varchar typed attributes
  *
  * @param int $pid
  *            : product id
  * @param array $item
  *            : item to inges
  * @param int $storeid
  *            : store for attribute value storage
  * @param int $attrcode
  *            : attribute code
  * @param array $attrdesc
  *            : attribute metadata
  * @param mixed $ivalue
  *            : input value to import
  * @return new int value to set
  *        
  *         Special case for multiselect
  */
 public function handleVarcharAttribute($pid, &$item, $storeid, $attrcode, $attrdesc, $ivalue)
 {
     $exists = $this->currentItemExists();
     // Check store specific value & empty & new item => ignore
     if ($storeid !== 0 && empty($ivalue) && !$exists) {
         return false;
     }
     // item exists , empty value, remove value, back to admin
     if ($ivalue == "" && $exists) {
         return "__MAGMI_DELETE__";
     }
     // default value exists, return it
     $dval = $this->getDefaultValue($attrdesc, $ivalue);
     if ($dval !== null) {
         return $dval;
     }
     $ovalue = $ivalue;
     $attid = $attrdesc["attribute_id"];
     // --- Contribution From mennos , optimized by dweeves ----
     // Added to support multiple select attributes
     // (as far as i could figure out) always stored as varchars
     // if it's a multiselect value
     if ($attrdesc["frontend_input"] == "multiselect") {
         // if empty delete entry
         if ($ivalue == "") {
             return "__MAGMI_DELETE__";
         }
         // magento uses "," as separator for different multiselect values
         $sep = Magmi_Config::getInstance()->get("GLOBAL", "multiselect_sep", ",");
         $multiselectvalues = explode($sep, $ivalue);
         $oids = $this->getOptionIds($attid, $storeid, $multiselectvalues);
         $ovalue = implode(",", $oids);
         unset($oids);
     }
     return $ovalue;
 }
コード例 #17
0
 public function initialize($params)
 {
     $magdir = Magmi_Config::getInstance()->getMagentoDir();
     $this->_mdh = MagentoDirHandlerFactory::getInstance()->getHandler($magdir);
 }
コード例 #18
0
 public function initialize($params)
 {
     $magdir = Magmi_Config::getInstance()->getMagentoDir();
     $this->_mdh = MagentoDirHandlerFactory::getInstance()->getHandler($magdir);
     $this->log("Using execution mode :" . $this->_mdh->getexecmode(), "startup");
 }
コード例 #19
0
 /**
  * copy image file from source directory to
  * product media directory
  *
  * @param $imgfile :
  *            name of image file name in source directory
  * @return : name of image file name relative to magento catalog media dir,including leading
  *         directories made of first char & second char of image file name.
  */
 public function copyImageFile($imgfile, &$item, $extra)
 {
     if ($imgfile == "__NULL__" || $imgfile == null) {
         return false;
     }
     // check for source image in error
     if ($this->isErrorImage($imgfile)) {
         if ($this->_newitem) {
             $this->fillErrorAttributes($item);
         }
         return false;
     }
     $source = $this->findImageFile($imgfile);
     if ($source == false) {
         $this->log("{$imgfile} cannot be found in images path", "warning");
         // last image in error,add it to error cache
         $this->setErrorImg($imgfile);
         return false;
     }
     $imgfile = $source;
     $checkexist = $this->getParam("IMG:existingonly") == "yes";
     $curlh = false;
     $bimgfile = $this->getTargetName($imgfile, $item, $extra);
     // source file exists
     $i1 = $bimgfile[0];
     $i2 = $bimgfile[1];
     // magento image value (relative to media catalog)
     $impath = "/{$i1}/{$i2}/{$bimgfile}";
     // target directory;
     $l2d = "media/catalog/product/{$i1}/{$i2}";
     // test for existence
     $targetpath = "{$l2d}/{$bimgfile}";
     /* test for same image (without problem) */
     if ($impath == $this->_lastimage) {
         return $impath;
     }
     /* test if imagefile comes from export */
     if (!$this->_mdh->file_exists($targetpath) || $this->getParam("IMG:writemode") == "override") {
         // if we already had problems with this target,assume we'll get others.
         if ($this->isErrorImage($impath)) {
             return false;
         }
         /* try to recursively create target dir */
         if (!$this->_mdh->file_exists($l2d)) {
             $tst = $this->_mdh->mkdir($l2d, Magmi_Config::getInstance()->getDirMask(), true);
             if (!$tst) {
                 // if we had problem creating target directory,add target to error cache
                 $errors = $this->_mdh->getLastError();
                 $this->log("error creating {$l2d}: {$errors["type"]},{$errors["message"]}", "warning");
                 unset($errors);
                 $this->setErrorImg($impath);
                 return false;
             }
         }
         if (!$this->saveImage($imgfile, $targetpath)) {
             $errors = $this->_mdh->getLastError();
             $this->fillErrorAttributes($item);
             $this->log("error copying {$l2d}/{$bimgfile} : {$errors["type"]},{$errors["message"]}", "warning");
             unset($errors);
             $this->setErrorImg($impath);
             return false;
         } else {
             @$this->_mdh->chmod("{$l2d}/{$bimgfile}", Magmi_Config::getInstance()->getFileMask());
         }
     }
     $this->_lastimage = $impath;
     /* return image file name relative to media dir (with leading / ) */
     return $impath;
 }
コード例 #20
0
 public function engineInit($params)
 {
     $this->_profile = $this->getParam($params, "profile", "default");
     // create an instance of local magento directory handler
     // this instance will autoregister in factory
     $mdh = new LocalMagentoDirHandler(Magmi_Config::getInstance()->getMagentoDir());
     $this->_timecounter->initTimingCats(array("global", "line"));
     $this->initPlugins($this->_profile);
     $this->mode = $this->getParam($params, "mode", "update");
 }
コード例 #21
0
 /**
  * copy image file from source directory to
  * product media directory
  * @param $imgfile : name of image file name in source directory
  * @return : name of image file name relative to magento catalog media dir,including leading
  * directories made of first char & second char of image file name.
  */
 public function copyImageFile($imgfile, &$item, $extra)
 {
     if ($imgfile == $this->_lastnotfound) {
         if ($this->_newitem) {
             $this->fillErrorAttributes($item);
         }
         return false;
     }
     $source = $this->findImageFile($imgfile);
     if ($source == false) {
         $this->log("{$imgfile} cannot be found in images path", "warning");
         return false;
     }
     $imgfile = $source;
     $checkexist = $this->getParam("IMG:existingonly") == "yes";
     $curlh = false;
     $bimgfile = $this->getTargetName($imgfile, $item, $extra);
     //source file exists
     $i1 = $bimgfile[0];
     $i2 = $bimgfile[1];
     $l2d = "media/catalog/product/{$i1}/{$i2}";
     $te = "{$l2d}/{$bimgfile}";
     $result = "/{$i1}/{$i2}/{$bimgfile}";
     /* test for same image */
     if ($result == $this->_lastimage) {
         return $result;
     }
     /* test if imagefile comes from export */
     if (!$this->_mdh->file_exists("{$te}") || $this->getParam("IMG:writemode") == "override") {
         /* try to recursively create target dir */
         if (!$this->_mdh->file_exists("{$l2d}")) {
             $tst = $this->_mdh->mkdir($l2d, Magmi_Config::getInstance()->getDirMask(), true);
             if (!$tst) {
                 $errors = $this->_mdh->getLastError();
                 $this->log("error creating {$l2d}: {$errors["type"]},{$errors["message"]}", "warning");
                 unset($errors);
                 return false;
             }
         }
         if (!$this->saveImage($imgfile, "{$l2d}/{$bimgfile}")) {
             $errors = $this->_mdh->getLastError();
             $this->fillErrorAttributes($item);
             $this->log("error copying {$l2d}/{$bimgfile} : {$errors["type"]},{$errors["message"]}", "warning");
             unset($errors);
             return false;
         } else {
             @$this->_mdh->chmod("{$l2d}/{$bimgfile}", Magmi_Config::getInstance()->getFileMask());
         }
     }
     $this->_lastimage = $result;
     /* return image file name relative to media dir (with leading / ) */
     return $result;
 }
コード例 #22
0
 public final function pluginInit($mmi, $meta, $params = null, $doinit = true, $profile = null)
 {
     $this->bind($mmi);
     $this->_pluginmeta = $meta;
     $this->_class = get_class($this);
     $this->_config = new Magmi_PluginConfig(get_class($this), $profile);
     $this->_config->load();
     $this->_magmiconfig = Magmi_Config::getInstance();
     $this->_params = $params != null ? array_merge($this->_config->getConfig(), $params) : $this->_config->getConfig();
     if (isset($mmi)) {
         $this->pluginHello();
     }
     if ($doinit) {
         $this->initialize($this->_params);
     }
 }
コード例 #23
0
<?php

require_once "../inc/magmi_config.php";
$conf = new Magmi_Config();
if ($conf->save($_POST)) {
    $date = filemtime($conf->getConfFile());
    echo "Common Configuration saved (" . strftime("%c", $date) . ")";
} else {
    $lasterr = error_get_last();
    echo "<div class='error'>" . $lasterr['message'] . "</div>";
}
コード例 #24
0
 /**
  * attribute handler for varchar based attributes
  * @param int $pid : product id
  * @param string $ivalue : attribute value
  * @param array $attrdesc : attribute description
  */
 public function handleVarcharAttribute($pid, &$item, $storeid, $attrcode, $attrdesc, $ivalue)
 {
     if ($storeid !== 0 && empty($ivalue) && $this->getImportMode() == "create") {
         return false;
     }
     if ($ivalue == "" && $this->getImportMode() == "update") {
         return "__MAGMI_DELETE__";
     }
     $ovalue = $ivalue;
     $attid = $attrdesc["attribute_id"];
     //--- Contribution From mennos , optimized by dweeves ----
     //Added to support multiple select attributes
     //(as far as i could figure out) always stored as varchars
     //if it's a multiselect value
     if ($attrdesc["frontend_input"] == "multiselect") {
         //if empty delete entry
         if ($ivalue == "") {
             return "__MAGMI_DELETE__";
         }
         //magento uses "," as separator for different multiselect values
         $sep = Magmi_Config::getInstance()->get("GLOBAL", "multiselect_sep", ",");
         $multiselectvalues = explode($sep, $ivalue);
         $oids = $this->getOptionIds($attid, $storeid, $multiselectvalues);
         $ovalue = implode(",", $oids);
         unset($oids);
     }
     return $ovalue;
 }
コード例 #25
0
 public static function getInstance()
 {
     if (self::$_instance == null) {
         self::$_instance = new Magmi_Config();
     }
     return self::$_instance;
 }
コード例 #26
0
<?php

require_once "../inc/magmi_config.php";
$currentprofile = $_REQUEST["profile"];
if ($currentprofile == "default") {
    $currentprofile = null;
}
$newprofile = $_REQUEST["newprofile"];
if ($newprofile != "") {
    $bcfg = new EnabledPlugins_Config($currentprofile);
    $confdir = Magmi_Config::getInstance()->getConfDir();
    $npdir = $confdir . DS . $newprofile;
    mkdir($npdir, Magmi_Config::getInstance()->getDirMask());
    $cpdir = $bcfg->getProfileDir();
    $filelist = scandir($cpdir);
    foreach ($filelist as $fname) {
        if (substr($fname, -5) == ".conf") {
            copy($cpdir . DS . $fname, $npdir . DS . $fname);
        }
    }
} else {
    $newprofile = $currentprofile;
}
header("Location:magmi.php?configstep=2&profile={$newprofile}");