Convert Adapter导入过程中如何显示通知或成功信息?

How to display notice or success message during the import by Convert Adapter?

Convert Adapter 在导入过程中如何显示通知或成功消息?

我只能通过

显示错误

Mage::throwException($message)

。 Class 对此负责的是 Mage_Adminhtml_Block_System_Convert_Profile_Run.

Magento 实际上有某种会话消息栈。 (与您可以在 Symphony 上找到的消息包非常相似的东西)。

这些都非常容易使用,只需获取与您所在区域相关联的会话并使用函数 addErroraddWarningaddNotice 或 [=16] =].

由于您在数据流模块上,因此您要查看的会话是 dataflow/session。注意通过单例获取此模型,否则,您最终会得到奇怪的多个会话。

Mage::getSingleton('dataflow/session')->addSuccess($this->__('This will add a success message'));

其他是:

Mage::getSingleton('dataflow/session')->addNotice($this->__('This a notice'));
Mage::getSingleton('dataflow/session')->addWarning($this->__('That a warning'));
Mage::getSingleton('dataflow/session')->addError($this->__('And finally an error'));

当你抛出异常时你实际上得到一个错误消息的原因是因为在 Magento 核心的某个地方,有一个

try {
    // the code or class instantiation on which you throw your exception happens here
} catch (Mage_Core_Exception $e) {
    Mage::getSingleton('dataflow/session')->addError($e->getMessage());
}