1

私は Magento Community 1.6.1.0 を使用しており、管理者が手動の再インデックス作成をいつ開始したか、およびその再インデックス作成にかかる時間 (つまり、開始と停止の時間) を追跡したいと考えています。出力は次のようになります。

Reindex process name, Datetime, Admin User, Start/End

これは、データ入力戦略を最適化し、どのプロセスに時間がかかり、誰がそのプロセスをいつ開始しているかを確認するのに役立つ貴重な情報になると思います。

Enterprise バージョンの管理者ログを操作しましたが、すべてをキャプチャすることはできません (そのためだけに Enterprise にアップグレードするつもりはありません)。これにアプローチする方法について何か考えはありますか?

4

1 に答える 1

0

これを実現するには、以下を拡張するカスタム モジュールを作成する必要があります。

/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');
}
于 2012-10-02T23:35:44.283 に答える