Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Getting an error: Fatal error: Class ‘Mage_[Namespace]_[Module]_Helper_Data’ not found in magento/app/Mage.php on line 520
 
parkeyparker
Jr. Member
 
Total Posts:  12
Joined:  2011-03-08
 

Hello, I am just starting out creating a module for Magento and I have hit a small but annoying roadblock. Whenever I try to access the Configuration pages (Admin Menu > System > Configuration) I encounter the following error:

Fatal error: Class 'Mage_Gosquared_Livestats_Helper_Data' not found in /var/www/magento/app/Mage.php on line 520
This is obviously a problem as it means I can’t configure the module to actually use it. Gosquared is my namespace and Livestats is my module name.

I have already tweeted my problem to @ask_magento and got some pretty good responses, but nothing yet has solved my problem and so I am posting this so that I can upload my config.xml file and see if that helps anyone. I can upload the entire module if needed, but would prefer not to at this stage… Open to anything that could fix this though so will of course upload if it’s needed.

Thank you in advance for any help you can provide, and if there is any more info that you need, just let me know!

Thanks

Aaron Parker

File Attachments
config.xml  (File Size: 1KB - Downloads: 120)
 
Magento Community Magento Community
Magento Community
Magento Community
 
Damian Culotta
Enthusiast
 
Total Posts:  878
Joined:  2008-12-10
Argentina
 

We can assume that you have the class /app/code/local/Gosquared/Livestats/Helper/Data.php and the class name is Gosquared_Livestats_Helper_Data.
Is this correct?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brent W Peterson
Moderator
 
Avatar
Total Posts:  3217
Joined:  2009-02-26
Minneapolis MN
 

How are you calling your helper/

You should do it like this Mage::helper(’your_module’)->YourMethod();

Your helper file should be called Data.php

 
Magento Community Magento Community
Magento Community
Magento Community
 
parkeyparker
Jr. Member
 
Total Posts:  12
Joined:  2011-03-08
 

Yes, that is correct. The contents of Data.php are:

<?php  
class Gosquared_Livestats_Helper_Data extends Mage_Core_Helper_Abstract {
    
}

Thanks again

Aaron

 
Magento Community Magento Community
Magento Community
Magento Community
 
uguptu
Sr. Member
 
Avatar
Total Posts:  125
Joined:  2010-02-01
Kyiv, Ukraine
 

I am sure the answer to the problem is pretty simple: the custom module is really located in app/code/local/Gosquared/Livestats directory, but the configuration file config.xml doesn’t have the node //global/helpers/gosquared_livestats/class with the content “Gosquared_Livestats_Helper”

I also assume there are no similar settings for //global/models and //global/blocks either.

 
Magento Community Magento Community
Magento Community
Magento Community
 
parkeyparker
Jr. Member
 
Total Posts:  12
Joined:  2011-03-08
 

The only place I appear to be using the helper is here:

<?php
class Gosquared_Livestats_Model_Config_Source_Username {
    
public function toOptionArray() {
        
return array(
            array(
'value'=>0'label'=>Mage::helper('livestats')->__('Off')),
            array(
'value'=>1'label'=>Mage::helper('livestats')->__('User ID')),
            array(
'value'=>2'label'=>Mage::helper('livestats')->__('Username'))
        );
    
}
}

Have just searched through for anything else and that is it…

 
Magento Community Magento Community
Magento Community
Magento Community
 
uguptu
Sr. Member
 
Avatar
Total Posts:  125
Joined:  2010-02-01
Kyiv, Ukraine
 

No matter WHERE are you using the helper, Magento is trying to resolve the real helper’s class name in Mage::helper and fails because you don’t have corresponding config node set up.

Am I right?

 
Magento Community Magento Community
Magento Community
Magento Community
 
parkeyparker
Jr. Member
 
Total Posts:  12
Joined:  2011-03-08
 

Sorry, I’m not quite sure I understand what you mean by corresponding config node… I think the easiest way is going to be for me to just upload the entire module… I have been following the wiki mainly for information on how to create the config.xml file but I may have overlooked something.

I have attached a zip file with the module code in it.

Thanks again

Aaron Parker

File Attachments
GoSquared-Magento-Module 2.zip  (File Size: 21KB - Downloads: 74)
 
Magento Community Magento Community
Magento Community
Magento Community
 
uguptu
Sr. Member
 
Avatar
Total Posts:  125
Joined:  2010-02-01
Kyiv, Ukraine
 

Simply put, to have the statement

Mage::helper(\'livestats\')

working, you have to have the following text in your config:

<config>
    <!-- ... -->

    <global>
        <!-- ... -->

        <
helpers>
            <
livestats>
                <class>
Gosquared_Livestats_Helper</class>
            </
livestats>
        </
helpers>

        <!-- ... -->
    </global>

    <!-- ... -->
</
config>
 
Magento Community Magento Community
Magento Community
Magento Community
 
parkeyparker
Jr. Member
 
Total Posts:  12
Joined:  2011-03-08
 

Yeah that is how my config.xml file is setup… Does it matter where within <globals /> <helpers /> goes? At the moment it is below <modules />:

<global>
        <
blocks>
            <
livestats>
                <class>
Gosquared_Livestats_Block</class>
            </
livestats>
        </
blocks>
        <
models>
            <
livestats>
                <class>
Gosquared_Livestats_Model</class>
            </
livestats>
        </
models>
        <
helpers>
            <
livestats>
                <class>
Gosquared_Livestats_Helper</class>
            </
livestats>
        </
helpers>
    </global>
 
Magento Community Magento Community
Magento Community
Magento Community
 
uguptu
Sr. Member
 
Avatar
Total Posts:  125
Joined:  2010-02-01
Kyiv, Ukraine
 

No matter where it goes in the config as far as it goes in the right level…

Hmm… your config looks ok, I believe there is only one option left: kill the /var/cache directory right now and check again. Seems that your cache is on.

 
Magento Community Magento Community
Magento Community
Magento Community
 
parkeyparker
Jr. Member
 
Total Posts:  12
Joined:  2011-03-08
 

Unfortunately that has had no effect, I’ve cleared the caches, turned them off and turned off compilation as well as logged in and out a few times too… Really stumped by this! :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
Japhet Perez
Jr. Member
 
Total Posts:  3
Joined:  2010-07-19
 

Did you make an double-check in your folder structure?

I mean:
local/Gosquared/Livestats
local/Gosquared/Livestats/Block
local/Gosquared/Livestats/Helper
local/Gosquared/Livestats/Model

Please, remember the uppercase capital letter in each folder.

Clean your cache, your sessions, everything.

Do you have any public demo of this error?

Best.
Japhet Pérez Atristain
HiPXiK.com
IT

 
Magento Community Magento Community
Magento Community
Magento Community
 
parkeyparker
Jr. Member
 
Total Posts:  12
Joined:  2011-03-08
 

Yep, my folder structures all look fine (There is a zip file with them in in an above reply) and I have cleared caches and things to no avail… And unfrortunately no, there is no public version of this I could show you at the moment… I am running from a VM on my laptop but will talk to a colleague and see if I can sort something out to allow you guys to see the problem (Also remember the error occurs in the admin panel so I would need to create an account for you to use...)

Thanks so much for everyone trying to help, I’m sure it’s something small that I’m overlooking but I just can’t see it as i’ve been staring at it for too long now! :(

Thanks

Aaron

 
Magento Community Magento Community
Magento Community
Magento Community
 
uguptu
Sr. Member
 
Avatar
Total Posts:  125
Joined:  2010-02-01
Kyiv, Ukraine
 

Okay, I’ve got an answer for you smile

Please note you have your helpers, as well as models and blocks, declared to be called as “livestats/some_thing”, right? Yet in the system.xml file, where you were mentioning modules you wanted to use for XML node translations, you mentioned “gosquared_livestats” and then “gosquared_ivestats”. No wonder Magento cannot build a proper helper path for the translations.

Either be consistent and always use “livestats”, or be correct and always use prefixed variant, “gosquared_livestats”, but use the same node names under //global/models, //global/blocks and //global/helpers in the config.

I tried your module and it worked for me, so just put all helper namespaces identically and you’ll have what you need.

 
Magento Community Magento Community
Magento Community
Magento Community
 
uguptu
Sr. Member
 
Avatar
Total Posts:  125
Joined:  2010-02-01
Kyiv, Ukraine
 

Two more recommendations inspired by the checking out your code:

1. Building up your default helper, derive it from Mage_Core_Helper_Data rather than from Mage_Core_Helper_Abstract.
2. Creating a block, suggest NEVER to build HTML directly in the block’s _toHtml() method, use a template instead. Anyway, inheriting your block from Mage_Core_Block_Text doesn’t make you any good when you are hacking it’s _toHtml(), it just makes no sence. If you prefer to ignore my buzz and still render HTML directly, use Mage_Core_Block_Abstract as an ancestor. smile

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2