9

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

jmventar
  • 687
  • 1
  • 11
  • 32
Jason Millward
  • 243
  • 2
  • 8
  • 15
  • I have a similar error with a another modules: ERR (3): Warning: include(Mage/Adjgiftreg/Helper/Data.php): failed to open stream: No such file or directory in ... where do you call echo Mage::helper('SEO')->getFullProductUrl($product); ?? – Leoh Jan 26 '17 at 17:53

2 Answers2

21

Your first problem is the config.xml. You have to tell Magento which class you're using.

...Other Stuff...
<global>
  ...Other Stuff...
  <helpers>
    <SEO>
      <class>SEO_Fullurl_Helper</class>
    </SEO>
   </helpers>
   ...Other Stuff...
</global>
...Other Stuff...

Then you need a Helper in app/code/local/SEO/Fullurl/Helper/Data.php that looks like this:

class SEO_Fullurl_Helper_Data extends Mage_Core_Helper_Abstract
{

    function getFullProductUrl( $product )
    {
    }
}

Then you can do echo Mage::helper('SEO')->getFullProductUrl($product);

Max
  • 8,671
  • 4
  • 33
  • 46
  • Thanks for the reply - in config.xml when you say "other stuff..." what do you mean? Am I missing something from the file? – Jason Millward Feb 19 '12 at 21:13
  • 1
    You are missing a _lot_ of stuff! Read http://alanstorm.com/magento_config to learn about the configuration files. If you want Blocks, Controllers, or Models you will have to declare them in config.xml also. Read more on http://alanstorm.com/category/magento – Max Feb 19 '12 at 21:41
1

I had missed the step of adding the module to app/etc/modules/SEO_Fullurl.xml

<?xml version="1.0"?>
<config>
    <modules>
        <SEO_Fullurl>
            <active>true</active>
            <codePool>local</codePool>
        </SEO_Fullurl>
    </modules>
</config>

I hope this helps someone, very easy mistake to make.

nickspiel
  • 5,170
  • 6
  • 33
  • 48