I'm using Magmi 7.18 to import the product catalog into Magento. I have the "On the Fly Indexer" selected, however after running the import the website front end does not reflect the correct information. I have to run the import through Magmi, and then go into Magento and clear out the cache. Does Magmi not already have the functionality to do this clearing after running the Import profile?
1 Answers
1
votes
I'm assuming that you are referring to the plugin Magmi Magento Reindexer. This plugin only updates the indices. It doesn't touch the cache at all.
It basically just a wrapper for shell/indexer.php
. Doing this:
php indexer.php reindexall
The code:
$cl = $this->getParam("REINDEX:phpcli") . " shell/indexer.php";
$out = $this->_mdh->exec_cmd($cl, "--reindex $idx", $this->_mdh->getMagentoDir());
It is fairly trivial to create a plugin in that clears the cache as well. I'm thinking it you could write a wrapper for n98-magerun.
Something like this should work:
<?php
class Magmi_Clearcache_Plugin extends Magmi_GeneralImportPlugin
{
protected $_mdh;
public function getPluginInfo()
{
return array(
"name" => "n98-magerun cache clear",
"author" => "mblarsen",
"version" => "0.1.0"
);
}
public function afterImport()
{
$this->log("Clearing cache", "info");
$this->clearCache();
return true;
}
public function updateIndexes()
{
$this->log("Clearing cache ....", "info");
$out = $this->_mdh->exec_cmd('n98-magerun', "cache:flush", $this->_mdh->getMagentoDir());
$this->log($out, "info");
$this->log("Done", "info");
}
public function isRunnable()
{
return array(FSHelper::getExecMode() != null,"");
}
public function initialize($params)
{
$magdir = Magmi_Config::getInstance()->getMagentoDir();
$this->_mdh = MagentoDirHandlerFactory::getInstance()->getHandler($magdir);
$this->log("Using execution mode:" . $this->_mdh->getexecmode(), "startup");
}
}
This assumes that you have n98-magerun in your magento root dir. Drop this in: plugins/extra/general/clearcache/magmi_clearcache_plugin.php