Diego
Diego

Reputation: 7562

Helper class not found

I'm trying to develop an extension that would add a form on the Admin side of Magento, but, for some reason, I can't seem to be able to even get Magento Administration to load when my module is installed. I'm at the very beginning of the development, and I'm stuck on an error that has been reported several times on StackOverflow. Unfortunately, none of the answers seem to help in my case.

The error I get is *Fatal error: Class 'Mage_Mycompany_Logviewer_Helper_Data' not found in C:\XAMPP\htdocs\magento\app\Mage.php on line 546*. That should mean that Magento can't find the helper class, but it's there and its name matches the one it's looking for (except for the "Mage_" at the beginning, that I never used in any other extension anyway).

Update 2012/07/29
The error occurs as soon as I log in into Magento Admin. When I click "Login", all I get is an error page, nothing is rendered.

Here's the content of all the files I have so far.

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mycompany_Logviewer>
            <version>0.1.0</version>
        </Mycompany_Logviewer>
    </modules>

    <global>
        <models>
            <logviewer>
                <class>Mycompany_Logviewer_Model</class>
            </logviewer>
        </models>
        <blocks>
            <logviewer>
                <class>Mycompany_Logviewer_Block</class>
            </logviewer>
        </blocks>
        <helpers>
            <logviewer>
                <class>Mycompany_Logviewer_Helper</class>
            </logviewer>
        </helpers>
    </global>

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <mycompany_logviewer after="Mage_Adminhtml">Mycompany_Logviewer_Adminhtml</mycompany_logviewer>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

    <adminhtml>
        <menu>
            <mycompany translate="title" module="mycompany_logviewer">
                <title>Mycompany</title>
                <sort_order>90</sort_order>
                <children>
                    <form translate="title" module="mycompany_logviewer">
                        <title>Form</title>
                        <sort_order>10</sort_order>
                        <action>adminhtml/logviewer</action>
                    </form>
                </children>
            </mycompany>
        </menu>

        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <mycompany>
                            <title>Mycompany</title>
                            <sort_order>90</sort_order>
                            <children>
                                <form>
                                    <title>Form</title>
                                    <sort_order>10</sort_order>
                                </form>
                            </children>
                        </mycompany>
                    </children>
                </admin>
            </resources>
        </acl>
    </adminhtml>
</config>

Data.php (Helper)

class Mycompany_Logviewer_Helper_Data extends Mage_Core_Helper_Abstract
{
}

LogviewerController.php (Controller)

class Mycompany_Logviewer_Adminhtml_LogviewerController extends Mage_Adminhtml_Controller_Action
{
    /**
    * View form action
    */
    public function indexAction() {
        $this->loadLayout();
        $this->_setActiveMenu('Mycompany/form');
        $this->_addBreadcrumb(Mage::helper('Mycompany_Logviewer')->__('Form'), Mage::helper('Mycompany_Logviewer')->__('Form'));
        $this->renderLayout();
    }

    /**
    * Check allow or not access to ths page
    *
    * @return bool - is allowed to access this menu
    */
    protected function _isAllowed()
    {
        return Mage::getSingleton('admin/session')->isAllowed('Mycompany/form');
    }
}

Mycompany_Logviewer.xml (configuration file)

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

All the above have been copied from an example I found online, I just replaced the Namespace and the Module name with Mycompany and Logviewer, respectively. I'm pretty sure it's something obvious I forgot, but I can't figure out what it could be. Thanks for the help.

Upvotes: 1

Views: 6719

Answers (2)

nordashi
nordashi

Reputation: 76

I had similar problem. Solution was putting company name in like this:

<helpers>
    <Mycompany_Logviewer>
        <class>Mycompany_Logviewer_Helper</class>
    </Mycompany_Logviewer>
</helpers>

$myHelper= Mage::helper('Mycompany_Logviewer');

Upvotes: 2

Drew Hunter
Drew Hunter

Reputation: 10114

The first thing that jumps out is that you are registering a module with the name of Procedo_Logviewer - when in fact it should be Mycompany_Logviewer

So, Mycompany_Logviewer.xml should be as follows:

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

Clear cache after changing

EDIT

Looking more closely at your controller, I can also see that you are calling your helper like so:

Mage::helper('Mycompany_Logviewer')

You should be calling your helper like this instead:

Mage::helper('logviewer')

EDIT 2

Another issue is present in your config.xml

module="mycompany_logviewer"

Should be

module="logviewer"

This correlates to the helper node you declared in your xml i.e.

<helpers>
    <logviewer>
        <class>Mycompany_Logviewer_Helper</class>
    </logviewer>
</helpers>

Upvotes: 4

Related Questions