我有一个执行代码的文件(js.phtml)。我需要访问一些用户数据。当我在js.phtml中使用error_log($ this)时,它显示“Mage_Core_Block_Template” - 这让我感到困惑。我期望这是父类,而不是传递给我的.phtml文件的类的价值。从Magento中的.phtml访问自定义变量
那么,我该如何与供应自定义对象或方法的一个.phtml文件?我是Magento的超级新手,我刚刚被放入任务中,因此我很抱歉使用错误的术语。
编辑: 我完整的文件路径是:
- /app/design/frontend//default/template/customer/welcome/js.phtml
还有一个完整的模块DIR这里:
- /应用/代码/本地//客户/
编辑: 我需要访问用户国家和用户ID。如果国家为空,那也没关系。
编辑: 我一直在做更多的研究,它看起来像我可以做这样的事情: Current user in Magento?
但我还没有在代码中还没有尝试过....
编辑:想通了:
error_log(print_r(Mage::getSingleton('customer/session')->getCustomer()->getEntityId(), true));
error_log(print_r(Mage::getSingleton('customer/session')->getCustomer()->getCountry(), true));
您需要使用哪些对象/方法?你能描述一下你的js.phtml文件试图完成什么吗? –
在OP中更新,好点。 –
你的路径有问题。默认主题模板文件夹的路径是'\ app \ design \ frontend \ base \ default \ template'。 – Zyava