当前位置: 首页>>代码示例>>PHP>>正文


PHP Magmi_Config类代码示例

本文整理汇总了PHP中Magmi_Config的典型用法代码示例。如果您正苦于以下问题:PHP Magmi_Config类的具体用法?PHP Magmi_Config怎么用?PHP Magmi_Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Magmi_Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateIndexes

 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();
     }
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:27,代码来源:magmi_reindexing_plugin.php

示例2: getMagentoBaseDir

 public function getMagentoBaseDir()
 {
     $magmi_conf = Magmi_Config::getInstance();
     $magmi_conf->load();
     $mbd = $magmi_conf->get("MAGENTO", "basedir");
     unset($magmi_conf);
     return $mbd;
 }
开发者ID:sickelap,项目名称:magento-finvalda,代码行数:8,代码来源:magmi_csvdatasource.php

示例3: getScanDir

 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;
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:8,代码来源:magmi_csvdatasource.php

示例4: getSessionConfig

function getSessionConfig()
{
    $conf = Magmi_Config::getInstance();
    if (isset($_SESSION['MAGMI_CONFIG_FILE'])) {
        $conf->load($_SESSION['MAGMI_CONFIG_FILE']);
    } else {
        $conf->load();
    }
    return $conf;
}
开发者ID:vikaskalra,项目名称:magmi-git,代码行数:10,代码来源:utils.php

示例5: testExistingProfileFromCustomFile

 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();
 }
开发者ID:marcellsauer,项目名称:magmi-git,代码行数:13,代码来源:ConfigSuiteTest.php

示例6: initialize

 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());
     }
 }
开发者ID:vstorm83,项目名称:ausport,代码行数:13,代码来源:magmi_engine.php

示例7: testCatMultiRoot

 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();
 }
开发者ID:bjoern-tantau,项目名称:magmi-git,代码行数:16,代码来源:PluginSuiteTest.php

示例8: checkPluginVersion

 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;
 }
开发者ID:vikaskalra,项目名称:magmi-git,代码行数:19,代码来源:008_magmi_remoteagent_plugin.php

示例9: processItemBeforeId

 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;
 }
开发者ID:marcellsauer,项目名称:magmi-git,代码行数:20,代码来源:valuetrimmer.php

示例10: __construct

 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;
     }
 }
开发者ID:kamilszewczyk,项目名称:magmi-git,代码行数:21,代码来源:magmi_auth.php

示例11: getRemoteFile

 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;
 }
开发者ID:marcellsauer,项目名称:magmi-git,代码行数:36,代码来源:magmi_csvdatasource.php

示例12: getClassInstance

{
    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
开发者ID:bjoern-tantau,项目名称:magmi-git,代码行数:31,代码来源:magmi.cli.php

示例13: getRemoteFile

 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;
 }
开发者ID:vstorm83,项目名称:ausport,代码行数:97,代码来源:magmi_csvdatasource.php

示例14: testGrouped

 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();
 }
开发者ID:GeekAb,项目名称:Crawlers,代码行数:17,代码来源:ImportSuite1Test.php

示例15: copyImageFile

 /**
  * 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));
//.........这里部分代码省略.........
开发者ID:vikaskalra,项目名称:magmi-git,代码行数:101,代码来源:imageitattributeemprocessor.php


注:本文中的Magmi_Config类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。