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

1
  • 3
    Did you clean out <webroot>/var/cache?
    – pspahn
    May 27, 2015 at 21:00

6 Answers 6

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');
13
  • I changed accordingly, but still its not working
    – Butterfly
    May 27, 2015 at 13:58
  • Have you seen my system.log error?
    – Butterfly
    May 27, 2015 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, 2015 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
    – Butterfly
    May 27, 2015 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). May 27, 2015 at 16:33
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?

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.

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>
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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.