PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/magmi/cli/magmi.cli.php

https://bitbucket.org/jit_bec/shopifine
PHP | 75 lines | 59 code | 8 blank | 8 comment | 6 complexity | 94470ca06514ae472789b9d02be1cb12 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. /**
  3. * MAGENTO MASS IMPORTER CLI SCRIPT
  4. *
  5. * version : 0.1
  6. * author : S.BRACQUEMONT aka dweeves
  7. * updated : 2010-08-02
  8. *
  9. */
  10. require_once("../inc/magmi_defs.php");
  11. $script=array_shift($argv);
  12. $options=array();
  13. foreach($argv as $option)
  14. {
  15. $isopt=$option[0]=="-";
  16. if($isopt)
  17. {
  18. $optarr=explode("=",substr($option,1),2);
  19. $optname=$optarr[0];
  20. if(count($optarr)>1)
  21. {
  22. $optval=$optarr[1];
  23. }
  24. else
  25. {
  26. $optval=1;
  27. }
  28. $options[$optname]=$optval;
  29. }
  30. }
  31. class CLILogger
  32. {
  33. public function log($data,$type)
  34. {
  35. echo("$type:$data\n");
  36. }
  37. }
  38. function getEngineInstance($options)
  39. {
  40. if(!isset($options["engine"]))
  41. {
  42. $options["engine"]="magmi_productimportengine:Magmi_ProductImportEngine";
  43. }
  44. $optname=$options["engine"];
  45. $engdef=explode(":",$optname);
  46. $engine_name=$engdef[0];
  47. $engine_class=$engdef[1];
  48. $enginst=null;
  49. $engfile=dirname(dirname(__FILE__))."/engines/$engine_name.php";
  50. if(file_exists($engfile))
  51. {
  52. require_once($engfile);
  53. if(class_exists($engine_class))
  54. {
  55. $enginst=new $engine_class();
  56. }
  57. }
  58. if($enginst==null)
  59. {
  60. die("Invalid engine definition : ".$optname);
  61. }
  62. return $enginst;
  63. }
  64. $importer=getEngineInstance($options);
  65. $importer->setLogger(new CLILogger());
  66. $importer->run($options);
  67. ?>