Since Magento EE 13.1 doesn't allow a full reindex in backend I developed an extension which provides a "Shell reindex" button in backend (on index management page) and suppose to run a full reindex. But it seems the "full reindex" will not be triggered, only product attributes seemed to be updated. Can anyone help me? Whats wrong with my module?
Thank you for everyone's help.
app/code/local/MyModule/ShellIndexer/controllers/Adminhtml/ProcessController.php
require_once 'Mage/Index/controllers/Adminhtml/ProcessController.php';
class MyModule_ShellIndexer_Adminhtml_ProcessController extends Mage_Index_Adminhtml_ProcessController {
public function shellAction() {
$process = Mage::getSingleton('index/indexer');
$collection=$process->getProcessesCollection();
$indexingProcesses = Mage::getSingleton('index/indexer')->getProcessesCollection();
foreach ($indexingProcesses as $process) {
$process->reindexEverything();
}
Mage::app()->getCacheInstance()->flush();
}
}
app/code/local/MyModule/ShellIndexer/Block/Adminhtml/Process.php
class MyModule_ShellIndexer_Block_Adminhtml_Process extends Enterprise_Index_Block_Adminhtml_Process {
public function __construct()
{
$this->_blockGroup = 'enterprise_index';
$this->_controller = 'adminhtml_process';
$this->_headerText = Mage::helper('index')->__('Index Management');
parent::__construct();
$this->_removeButton('add');
$url = Mage::helper("adminhtml")->getUrl("/process/shell");
$script = "new Ajax.Request('".$url."',{method:'post'});";
$this->_addButton('Shell ReIndex', array(
'label' => Mage::helper('index')->__('Shell Re-Index'),
'onclick' => $script,
'class' => 'save',
), -100);
}
}
etc/config.xml (not relevant for the issue, but if anyone wants to rebuild the extension)
<?xml version="1.0"?>
<config>
<modules>
<MyModule_ShellIndexer>
<version>1.0.0.0</version>
</MyModule_ShellIndexer>
</modules>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<MyModule_ShellIndexer before="Mage_Index_Adminhtml">MyModule_ShellIndexer_Adminhtml</MyModule_ShellIndexer>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<global>
<blocks>
<mymodule_shellindexer>
<class>MyModule_ShellIndexer_Block</class>
</mymodule_shellindexer>
<enterprise_index>
<rewrite>
<adminhtml_process>MyModule_ShellIndexer_Block_Adminhtml_Process</adminhtml_process>
</rewrite>
</enterprise_index>
</blocks>
</global>
</config>