Php 在Magento中调用帮助器类
我试图在Magento中创建自定义帮助器模块,但从页面调用时出现以下错误:Php 在Magento中调用帮助器类,php,magento,e-commerce,helpers,Php,Magento,E Commerce,Helpers,我试图在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 从模板中,我使用以下方法调用帮助器模块
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); ?>
Data.php调用函数:
<?php
class getFullProductUrl {
public function getFullProductUrl( $product )
{
}
您的第一个问题是config.xml。你必须告诉Magento你在使用哪个类
...Other Stuff...
<global>
...Other Stuff...
<helpers>
<SEO>
<class>SEO_Fullurl_Helper</class>
</SEO>
</helpers>
...Other Stuff...
</global>
...Other Stuff...
然后您可以执行echo Mage::helper('SEO')->getFullProductUrl($product)代码>我错过了将模块添加到app/etc/modules/SEO\u Fullurl.xml的步骤
<?xml version="1.0"?>
<config>
<modules>
<SEO_Fullurl>
<active>true</active>
<codePool>local</codePool>
</SEO_Fullurl>
</modules>
</config>
真的
地方的
我希望这能帮助一些人,很容易犯错误。谢谢你在config.xml中回答“其他东西…”你是什么意思?我是不是从档案里漏掉了什么?你漏掉了很多东西!阅读以了解有关配置文件的信息。如果需要块、控制器或模型,还必须在config.xml中声明它们。阅读更多关于另一个模块的类似错误:ERR(3):警告:include(Mage/Adjgiftreg/Helper/Data.php):无法打开流:中没有这样的文件或目录。。。在哪里调用echo-Mage::helper('SEO')->getFullProductUrl($product)??
...Other Stuff...
<global>
...Other Stuff...
<helpers>
<SEO>
<class>SEO_Fullurl_Helper</class>
</SEO>
</helpers>
...Other Stuff...
</global>
...Other Stuff...
class SEO_Fullurl_Helper_Data extends Mage_Core_Helper_Abstract
{
function getFullProductUrl( $product )
{
}
}
<?xml version="1.0"?>
<config>
<modules>
<SEO_Fullurl>
<active>true</active>
<codePool>local</codePool>
</SEO_Fullurl>
</modules>
</config>