我可以检测magento函数是否作为API调用运行吗?

ben*_*ben 2 api magento

我知道我可以检测管理员是否正在运行某个功能:

Mage::getSingleton('admin/session')->isLoggedIn();
Run Code Online (Sandbox Code Playgroud)

但我不确定是否有类似的调用来确定环境是API调用还是Web访问.

Jan*_*ing 12

您可以检查Mage_Api_Model_Server单例是否已初始化:

$apiRunning = Mage::getSingleton('api/server')->getAdapter() != null;
Run Code Online (Sandbox Code Playgroud)