Ala*_*orm 10 php oop events magento
在Magento电子商务系统中,有三个事件在系统完全自举之前触发
resource_get_tablename
core_collection_abstract_load_before
core_collection_abstract_load_after
Run Code Online (Sandbox Code Playgroud)
在 Magento引导后,这些事件也会发生.
什么是安全和优雅(也许事件Mage核心团队祝福)的方式来检测Magento 何时完全引导,以便您可以安全地使用这些事件?
如果您尝试在预引导状态下使用某些功能,则整个请求将为404. 到目前为止,我提出的最佳(上下文的自我链接)是这样的
class Packagename_Modulename_Model_Observer
{
public function observerMethod($observer)
{
$is_safe = true;
try
{
$store = Mage::app()->getSafeStore();
}
catch(Exception $e)
{
$is_safe = false;
}
if(!$is_safe)
{
return;
}
//if we're still here, we could initialize store object
//and should be well into router initialization
}
}
Run Code Online (Sandbox Code Playgroud)
但那有点笨拙.
我认为没有任何专门为此而设计的活动。
您可以添加您自己的并提交拉取请求/Magento 票证以包含一个好的请求。
在那之前,我认为唯一的方法是使用您发现的事件之一,并对 Magento 的初始化程度进行一些检查。
你尝试得到吗Mage::app()->getStores()?这可能会让您免于捕获异常。