Magento索引管理错误

Magento索引管理错误,magento,Magento,当我尝试重新编制索引时,出现了此错误 分析错误:语法错误,中出现意外的“')” 第137行的app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php 这是我的processcontroller文件 有什么建议吗 /** * Initialize process object by request * * @return Mage_Index_Model_Process|false */ protected f

当我尝试重新编制索引时,出现了此错误

分析错误:语法错误,中出现意外的“')”

第137行的app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php

这是我的processcontroller文件

有什么建议吗

/**
 * Initialize process object by request
 *
 * @return Mage_Index_Model_Process|false
 */
protected function _initProcess()
{
    $processId = $this->getRequest()->getParam('process');
    if ($processId) {
        /** @var $process Mage_Index_Model_Process */
        $process = Mage::getModel('index/process')->load($processId);
        if ($process->getId() && $process->getIndexer()->isVisible()) {
            return $process;
        }
    }
    return false;
}

/**
 * Display processes grid action
 */
public function listAction()
{
    $this->_title($this->__('System'))->_title($this->__('Index Management'));

    $this->loadLayout();
    $this->_setActiveMenu('system/index');
    $this->renderLayout();
}

/**
 * Process detail and edit action
 */
public function editAction()
{
    /** @var $process Mage_Index_Model_Process */
    $process = $this->_initProcess();
    if ($process) {
        $this->_title($process->getIndexCode());

        $this->_title($this->__('System'))
             ->_title($this->__('Index Management'))
             ->_title($this->__($process->getIndexer()->getName()));

        Mage::register('current_index_process', $process);
        $this->loadLayout();
        $this->renderLayout();
    } else {
        $this->_getSession()->addError(
            Mage::helper('index')->__('Cannot initialize the indexer process.')
        );
        $this->_redirect('*/*/list');
    }
}

/**
 * Save process data
 */
public function saveAction()
{
    /** @var $process Mage_Index_Model_Process */
    $process = $this->_initProcess();
    if ($process) {
        $mode = $this->getRequest()->getPost('mode');
        if ($mode) {
            $process->setMode($mode);
        }
        try {
            $process->save();
            $this->_getSession()->addSuccess(
                Mage::helper('index')->__('The index has been saved.')
            );
        } 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 saving process.')
            );
        }
        $this->_redirect('*/*/list');
    } else {
        $this->_getSession()->addError(
            Mage::helper('index')->__('Cannot initialize the indexer process.')
        );
        $this->_redirect('*/*/list');
    }
}

/**
 * Reindex all data what process is responsible
 */
public function reindexProcessAction()
{
    /** @var $process Mage_Index_Model_Process */
    $process = $this->_initProcess();
    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.'). $e->getMessage())
            );
        }
    } else {
        $this->_getSession()->addError(
            Mage::helper('index')->__('Cannot initialize the indexer process.')
        );
    }

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

/**
 * Reindex pending events for index process
 */
public function reindexEventsAction()
{

}

/**
 * Rebiuld all processes index
 */
public function reindexAllAction()
{

}

/**
 * Mass rebuild selected processes index
 *
 */
public function massReindexAction()
{
    /* @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 {
            $counter = 0;
            foreach ($processIds as $processId) {
                /* @var $process Mage_Index_Model_Process */
                $process = $indexer->getProcessById($processId);
                if ($process && $process->getIndexer()->isVisible()) {
                    $process->reindexEverything();
                    $counter++;
                }
            }
            $this->_getSession()->addSuccess(
                Mage::helper('index')->__('Total of %d index(es) have reindexed data.', $counter)
            );
        } 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.'));
        }
    }

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

/**
 * Mass change index mode of selected processes index
 *
 */
public function massChangeModeAction()
{
    $processIds = $this->getRequest()->getParam('process');
    if (empty($processIds) || !is_array($processIds)) {
        $this->_getSession()->addError(Mage::helper('index')->__('Please select Index(es)'));
    } else {
        try {
            $counter = 0;
            $mode = $this->getRequest()->getParam('index_mode');
            foreach ($processIds as $processId) {
                /* @var $process Mage_Index_Model_Process */
                $process = Mage::getModel('index/process')->load($processId);
                if ($process->getId() && $process->getIndexer()->isVisible()) {
                    $process->setMode($mode)->save();
                    $counter++;
                }
            }
            $this->_getSession()->addSuccess(
                Mage::helper('index')->__('Total of %d index(es) have changed index mode.', $counter)
            );
        } 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.'));
        }
    }

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

/**
 * Check ACL permissins
 *
 * @return bool
 */
protected function _isAllowed()
{
    return Mage::getSingleton('admin/session')->isAllowed('system/index');
}

替换为以下代码的函数
reindexProcessAction()

请注意,不编辑核心文件

public function reindexProcessAction()
{
    $process = $this->_initProcess();
    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.')
        );
    }
}

您是否尝试用原始版本替换此文件?这是一个核心文件,不应该对其进行编辑。我猜您的
reindexProcessAction
方法在第二个
catch
块的
$e->getMessage())
末尾有一个过多的右括号。我建议使用一些IDE,它至少会进行一些语法检查来显示这样的语法错误。