开发者

Magento Observer function with External PHP classes error

I am trying to accomplish something which I think is getting beyond my current PHP skills! I have working code in a Magento .phtml template file that calls an external PHP class e.g.

$ExternalLibPath=Mage::getModuleDir('', 'My_Mod开发者_如何学Pythonule') . DS . 'lib' . DS .'class.authentication.php';
require_once ($ExternalLibPath);
$myauth = new Authentication();
$credentials = $myauth->get("account_credentials");
echo "Connecting as " . $credentials->user_name ;

(In the .phtml file the classes are called from an include). I'm trying to move the code from the frontend template files to a Magento module/extension with a class triggered on an event. My module works fine up until the external classes are accessed where trying to access *$credentials->user_name* causes an Undefined property: stdClass: error.

I don't understand why the code works in a .phtml template and not in the module, or what I am doing wrong!

Any help would be appreciated.

Pete.


You should call the class directly from the phtml:

$credentials = Mage::getModel('namespace/custom_class')->getAccountCredentials();

and return whatever you need to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜