Magento:管理员启动手动重新索引时,以及开始和结束时,有没有办法记录日志?

Magento:管理员启动手动重新索引时,以及开始和结束时,有没有办法记录日志?,magento,logging,indexing,Magento,Logging,Indexing,我使用的是Magento Community 1.6.1.0,我想跟踪管理员何时开始手动重新编制索引,以及重新编制索引需要多长时间,即何时开始和停止。输出类似于: Reindex process name, Datetime, Admin User, Start/End 我认为这将是有价值的信息,有助于优化我们的数据输入策略,了解哪些流程需要很长时间,由谁启动,以及在一天中的什么时候启动 我已经使用了企业版的管理日志,但它并没有捕获所有的日志,我不打算为此升级到企业版。关于如何实现这一点,您有

我使用的是Magento Community 1.6.1.0,我想跟踪管理员何时开始手动重新编制索引,以及重新编制索引需要多长时间,即何时开始和停止。输出类似于:

Reindex process name, Datetime, Admin User, Start/End
我认为这将是有价值的信息,有助于优化我们的数据输入策略,了解哪些流程需要很长时间,由谁启动,以及在一天中的什么时候启动


我已经使用了企业版的管理日志,但它并没有捕获所有的日志,我不打算为此升级到企业版。关于如何实现这一点,您有什么想法吗?

要实现这一点,您需要创建一个自定义模块,扩展:

/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php

更新

public function reindexProcessAction()
{
    $process = $this->_initProcess();

    // start logger here and get admin user name

    if ($process) {
        try {
            Varien_Profiler::start('__INDEX_PROCESS_REINDEX_ALL__');

            $process->reindexEverything();
            Varien_Profiler::stop('__INDEX_PROCESS_REINDEX_ALL__');
            $this->_getSession()->addSuccess(
                Mage::helper('index')->__('%s index was rebuilt.', $process->getIndexer()->getName())
            );
        } catch (Mage_Core_Exception $e) {
            $this->_getSession()->addError($e->getMessage());
        } catch (Exception $e) {
            $this->_getSession()->addException($e,
                 Mage::helper('index')->__('There was a problem with reindexing process.')
            );
        }
    } else {
        $this->_getSession()->addError(
            Mage::helper('index')->__('Cannot initialize the indexer process.')
        );
    }

     // stop timer and write information to db or file

    $this->_redirect('*/*/list');
}


谢谢我会看看这个,让你知道我们是如何处理的。
public function massReindexAction()
{    
    // start logger here and get admin user name
    /* @var $indexer Mage_Index_Model_Indexer */
    $indexer    = Mage::getSingleton('index/indexer');
    $processIds = $this->getRequest()->getParam('process');
    if (empty($processIds) || !is_array($processIds)) {
        $this->_getSession()->addError(Mage::helper('index')->__('Please select Indexes'));
    } else {
        try {
            foreach ($processIds as $processId) {
                /* @var $process Mage_Index_Model_Process */
                $process = $indexer->getProcessById($processId);
                if ($process) {
                    $process->reindexEverything();
                }
            }
            $count = count($processIds);
            $this->_getSession()->addSuccess(
                Mage::helper('index')->__('Total of %d index(es) have reindexed data.', $count)
            );
        } catch (Mage_Core_Exception $e) {
            $this->_getSession()->addError($e->getMessage());
        } catch (Exception $e) {
            $this->_getSession()->addException($e, Mage::helper('index')->__('Cannot initialize the indexer process.'));
        }
    }
    // stop timer and write information to db or file
    $this->_redirect('*/*/list');
}