duanchi8836 2011-03-10 16:28
浏览 32

Magento Observer函数与外部PHP类错误

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_Module') . 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.

  • 写回答

1条回答 默认 最新

  • doudu161481 2011-03-10 17:01
    关注

    You should call the class directly from the phtml:

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

    and return whatever you need to.

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)