在 Magento 中调用辅助类
我正在尝试在 Magento 中创建自定义帮助程序模块,但是当我从页面调用它时,出现以下错误:
Warning: include(Mage/SEO/Helper/Data.php) [function.include]: failed to open stream: No such file or directory in /home/strailco/1stclassholidays.com/html/lib/Varien/Autoload.php on line 93
从模板中,我使用以下内容来调用帮助程序模块:
<?php echo Mage::helper('SEO')->getFullProductUrl($product); ?>
帮助程序模块设置如下:
/app/code/local/SEO/Fullurl/Helper/Data.php
/app/code/local/SEO/Fullurl/etc/config.xml
Data.php 调用该函数:
<?php
class getFullProductUrl {
public function getFullProductUrl( $product )
{
}
我的 config.xml 设置如下:
<?xml version="1.0"?>
<config>
<global>
<helpers>
<SEO>
<class>getFullProductUrl</class>
</SEO>
</helpers>
</global>
</config>
我认为问题在于我设置 config.xml 的方式,但我正在努力找出正确的方法这样做的方法。
如果您能提供任何帮助,我将不胜感激。我已经为此工作了几天,但无法使其发挥作用。
非常感谢
杰森
I'm trying to create a custom helper module in Magento but I'm getting the following error when I call it from a page :
Warning: include(Mage/SEO/Helper/Data.php) [function.include]: failed to open stream: No such file or directory in /home/strailco/1stclassholidays.com/html/lib/Varien/Autoload.php on line 93
From the template i am using the following to call the helper module:
<?php echo Mage::helper('SEO')->getFullProductUrl($product); ?>
The helper module is set up under:
/app/code/local/SEO/Fullurl/Helper/Data.php
/app/code/local/SEO/Fullurl/etc/config.xml
Data.php calls the function:
<?php
class getFullProductUrl {
public function getFullProductUrl( $product )
{
}
I have my config.xml set up like this:
<?xml version="1.0"?>
<config>
<global>
<helpers>
<SEO>
<class>getFullProductUrl</class>
</SEO>
</helpers>
</global>
</config>
I think the problem is the way I have the config.xml set up but I'm struggling to work out the correct way of doing this.
I would be very greatful of any help that you could give. I've been working on this for a couple of days but can't get it working.
Many Thanks
Jason
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的第一个问题是 config.xml。您必须告诉 Magento 您正在使用哪个类。
然后您需要在
app/code/local/SEO/Fullurl/Helper/Data.php
中添加一个如下所示的 Helper:然后您可以执行
echo Mage::helper('SEO') ->getFullProductUrl($product);
Your first problem is the config.xml. You have to tell Magento which class you're using.
Then you need a Helper in
app/code/local/SEO/Fullurl/Helper/Data.php
that looks like this:Then you can do
echo Mage::helper('SEO')->getFullProductUrl($product);
我错过了将模块添加到 app/etc/modules/SEO_Fullurl.xml 的步骤,
我希望这对某人有帮助,这是很容易犯的错误。
I had missed the step of adding the module to app/etc/modules/SEO_Fullurl.xml
I hope this helps someone, very easy mistake to make.