PageRenderTime 52ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/magmi/plugins/base/general/reindex/magmi_reindexing_plugin.php

https://bitbucket.org/jit_bec/shopifine
PHP | 74 lines | 64 code | 9 blank | 1 comment | 3 complexity | 22ea606cd20d07564ae82a1e70b5608e MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. class Magmi_ReindexingPlugin extends Magmi_GeneralImportPlugin
  3. {
  4. protected $_reindex;
  5. protected $_indexlist="catalog_product_attribute,catalog_product_price,catalog_product_flat,catalog_category_flat,catalog_category_product,cataloginventory_stock,catalog_url,catalogsearch_fulltext";
  6. public function getPluginInfo()
  7. {
  8. return array("name"=>"Magmi Magento Reindexer",
  9. "author"=>"Dweeves",
  10. "version"=>"1.0.5",
  11. "url"=>"http://sourceforge.net/apps/mediawiki/magmi/index.php?title=Magmi_Magento_Reindexer");
  12. }
  13. public function afterImport()
  14. {
  15. $this->log("running indexer","info");
  16. $this->updateIndexes();
  17. return true;
  18. }
  19. public function getPluginParamNames()
  20. {
  21. return array("REINDEX:indexes","REINDEX:phpcli");
  22. }
  23. public function getIndexList()
  24. {
  25. return $this->_indexlist;
  26. }
  27. public function updateIndexes()
  28. {
  29. //make sure we are not in session
  30. if(session_id()!=="")
  31. {
  32. session_write_close();
  33. }
  34. $magdir=Magmi_Config::getInstance()->getMagentoDir();
  35. $cl=$this->getParam("REINDEX:phpcli")." $magdir/shell/indexer.php";
  36. $idxlstr=$this->getParam("REINDEX:indexes","");
  37. $idxlist=explode(",",$idxlstr);
  38. if(count($idxlist)==0)
  39. {
  40. $this->log("No indexes selected , skipping reindexing...","warning");
  41. return true;
  42. }
  43. foreach($idxlist as $idx)
  44. {
  45. $tstart=microtime(true);
  46. $this->log("Reindexing $idx....","info");
  47. $out = shell_exec("$cl --reindex $idx");
  48. $this->log($out,"info");
  49. $tend=microtime(true);
  50. $this->log("done in ".round($tend-$tstart,2). " secs","info");
  51. if(Magmi_StateManager::getState()=="canceled")
  52. {
  53. exit();
  54. }
  55. flush();
  56. }
  57. }
  58. public function isRunnable()
  59. {
  60. return array(true,"");
  61. }
  62. public function initialize($params)
  63. {
  64. }
  65. }