9

I wrote a new extension and trying to create a configuration setting file in Magento Admin. When I run on browser after clearing the cache I got the error like below

Fatal error: Class 'Mage_GlobalSms_Helper_Data' not found in D:\wamp\www\project\app\Mage.php on line 547

In system.log error log file I found the error below:

2015-05-27T13:40:43+00:00 ERR (3): Warning: include(Mage\GlobalSms\Helper\Data.php): failed to open stream: No such file or directory  in D:\wamp\www\project\lib\Varien\Autoload.php on line 93
2015-05-27T13:40:43+00:00 ERR (3): Warning: include(): Failed opening 'Mage\GlobalSms\Helper\Data.php' for inclusion (include_path='D:\wamp\www\project\app\code\local;D:\wamp\www\project\app\code\community;D:\wamp\www\project\app\code\core;D:\wamp\www\project\lib;.;C:\php\pear')  in D:\wamp\www\project\lib\Varien\Autoload.php on line 93

My app\etc\modules\ file as below:

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

My config.xml as below:

<config>
<modules>
    <Ucs_GlobalSms>
        <version>0.0.1</version>
    </Ucs_GlobalSms>
</modules>
<admin>
     <routers>
        <adminhtml>
            <args>
                <modules>
                    <ucs_globalsms before="Mage_Adminhtml">Ucs_GlobalSms_Adminhtml</ucs_globalsms>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
<global>
    <helpers>
        <globalsms>
            <class>Ucs_GlobalSms_Helper</class>
        </globalsms>
    </helpers>
    <models>
        <custommodule>
            <class>Ucs_GlobalSms_Model</class>
        </custommodule>
    </models>
    <events>
        <customer_register_success>
            <observers>
                <Ucs_GlobalSms_customer_register_success>
                    <type>singleton</type>
                    <class>Ucs_GlobalSms_Model_Observer</class>
                    <method>customerRegisterSuccess</method>
                </Ucs_GlobalSms_customer_register_success>
            </observers>
        </customer_register_success>
    </events>
</global>

My Helper/Data.php as below:

<?php
class Php_GlobalSms_Helper_Data extends Mage_Core_Helper_Abstract {

}

I can find lot of posts on SO saying that Data.php is missing, but everything is there, still I am getting error

Anto S
  • 1,417
  • 5
  • 30
  • 56

6 Answers6

10

Your helpers declaration should look like this:

<global>
    <helpers>
        <globalsms>
            <class>Php_GlobalSms_Helper</class>
        </globalsms>
    </helpers>
</global>

and you should call your helper in the code like this:

Mage::helper('globalsms');
Marius
  • 197,939
  • 53
  • 422
  • 830
  • I changed accordingly, but still its not working – Anto S May 27 '15 at 13:58
  • Have you seen my system.log error? – Anto S May 27 '15 at 14:09
  • 1
    Yes. Check if your module is picked up by Magento. If it is, then it should work as I described. Maybe you should add to the question your full config.xml and the way you are using the helper – Marius May 27 '15 at 14:15
  • updated full config.xml, I am not calling helper file anywhere. If I dont declare that I am getting error, thats why I added the helper tag in xml – Anto S May 27 '15 at 14:30
  • The error being shown indicates that the group class name is not being picked up. This indicates that the config.xml is either not loaded or the configuration for the helper is in the wrong place. It should be in /config/global/helpers as noted in Marius' answer. (also note that the version should probably not be in the module XML file). – Kevin Schroeder May 27 '15 at 16:33
  • @version_0.1 Looks like you are missing the the <helpers> tag in your config.xml – Marius May 27 '15 at 20:15
  • @Marius im sorry, helper tag is there, I missed it when pasting it here. refer my edited post – Anto S May 28 '15 at 10:59
  • Everything looks ok, except maybe that the tag for models is custommodule instead of globalsms. It should work. Maybe something else is preventing your module from being picked up. – Marius May 28 '15 at 11:15
  • @Marius I found something interesting, I renamed my module as GlobalSms_old and created new GlobalSms folder and put my coding now its working fine.. I cant get any idea why it happens – Anto S May 28 '15 at 11:44
  • @Marius again I am facing the same issue, my module name is ImsServices inside Ucs folder, but it magento looks Helper data inside Imsservices . I have a problem when my module name is combination of two words, please help me out – Anto S May 10 '16 at 05:41
  • @invissible. Have you tried the code in the answer? – Marius May 10 '16 at 06:15
  • @Marius yes I tried it I defined my class as <class>Ucs_ImsServices_Helper</class> but in system.log getting error as Warning: include(Mage/Imsservices/Helper/Data.php): failed to open stream: I hope this is because of two word module name I defined as upper caseS for ImsServices but magento search Data.php indside lower case s Imsservices – Anto S May 10 '16 at 06:43
  • make sure you added the node inside the global tag and you cleared the cache. – Marius May 10 '16 at 06:52
  • @Butterfly you able to find out the issue?i am also facing the same helper not found issue even though the helper config was set fine. it is happening randomly i can see the logs on newrelic – Dhanasekar Jun 09 '23 at 06:24
  • @Dhanasekar Whats the log say? Are you using Magento 1? – Anto S Jun 09 '23 at 06:28
  • @Butterfly yes it is magento 1 and suddenly the error says Mage_Gs helper not found but my helper file is present under GS/my module – Dhanasekar Jun 10 '23 at 15:37
5

Your module name in module.xml is different in config.xml.

I'm not sure myself what you want to use, Php_GlobalSms or Ucs_GlobalSms?

Vernard Luz
  • 886
  • 4
  • 8
4

If you enable compilation (System > Tools > Compilation), you need to disable or re-compile it. It is the best that you disable Compilation when you do development.

Magebuzz
  • 389
  • 1
  • 4
2

You need to define your helper in the config.xml

<config>
<modules>
    <Php_GlobalSms>
        <version>0.0.1</version>
    </Php_GlobalSms>
</modules>
<admin>
     <routers>
        <adminhtml>
            <args>
                <modules>
                    <ucs_globalsms before="Mage_Adminhtml">Php_GlobalSms_Adminhtml</ucs_globalsms>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
<global>
    <models>
        <custommodule>
            <class>Php_GlobalSms_Model</class>
        </custommodule>
    </models>
    <helpers>
        <globalsms>
            <class>Php_GlobalSms_Helper</class>
        </globalsms>
    </helpers>
    <events>
        <customer_register_success>
            <observers>
                <Php_GlobalSms_customer_register_success>
                    <type>singleton</type>
                    <class>Php_GlobalSms_Model_Observer</class>
                    <method>customerRegisterSuccess</method>
                </Php_GlobalSms_customer_register_success>
            </observers>
        </customer_register_success>
    </events>
</global>
brianwalleshauser
  • 355
  • 1
  • 3
  • 11
1

I have same problem. I have check my config.xml and check my layout xml :

  <layout>
        <updates>
            <module_name>
                <file>module_name.xml</file>
            </module_name>
        </updates>
    </layout>

I have done mistake in module_name.xml. I have remove that code which is not needed.

alok
  • 241
  • 3
  • 3
1

You said that you created a configuration setting for the admin area; in the system.xml-file, I assume you have something like this (you should have):

<php_globalsms_options translate="label" module="php_globalsms">[...]

This is where Magento tries to load your helper: it handles the translation, regardless of the fact if you call the helper in any of your files or not. The other answers tell the correct way: update your config.xml file and tell Magento that the GlobalSms-helper resides in your module.

simonthesorcerer
  • 4,813
  • 2
  • 19
  • 32