1

There are at least a half dozen StackOverflow posts with quite similar issues and I've gone through all the comments on them. Eg: A, B, C. I've deleted the cache, turned off the compilation, set permissions, all to no avail. At first, I had some extra whitespace in my XML, but once I deleted that, I am now hitting the Data helper loading issue. It's getting the Mage namespace instead of my extension's Namespace.

I've got some frontend controllers, observers, and models working fine following these great videos and now going through Alan Storm's admin menu tutorial. I refreshed the admin page and now the header prints, but the entire admin below the header is not rendering due to a warning getting thrown.

In the log I see this:

2016-02-12T23:20:54+00:00 ERR (3): Warning: include(Mage/Namespace/Package/Helper/Data.php): failed to open stream: No such file or directory  in /var/www/magento1/lib/Varien/Autoload.php on line 94
2016-02-12T23:20:54+00:00 ERR (3): Warning: include(): Failed opening 'Mage/Namespace/Package/Helper/Data.php' for inclusion (include_path='/var/www/magento1/app/code/local:/var/www/magento1/app/code/community:/var/www/magento1/app/code/core:/var/www/magento1/lib:.:/usr/share/php:/usr/share/pear')  in /var/www/magento1/lib/Varien/Autoload.php on line 94

Now obviously the Helper class at app/code/community/Namespace/Package/Helper/Data.php is not being autoloaded correctly:

class Namespace_Package_Helper_Data extends Mage_Core_Helper_Abstract 
{
    public function test()
    {
        echo 'Helper loaded';
    }
}

Here's the relevant portion of app/code/community/Namespace/Package/etc/config.xml

<config>
    <global>
        <helpers>
            <namespace>
                <class>Namespace_Package_Helper</class>
            </namespace>
        </helpers>
    </global>
</config>

Note: I have frontend controllers, models, and observers already in this extension working fine and I've now started work on the admin side, this is the first time I've tried to add any adminhtml or admin controllers to the custom extension.

I don't even intend to use this Helper per se but it is needed for admin.

If I do this in /test.php:

$helper = Mage::helper('namespace/data');
$helper->test();

the helper is autoloaded and it prints "Helper loaded".

2 Answers 2

1

After hours of fiddling and searching, I found the magic sauce in a comment thread on this SO post. I had to expand the comments to find it!

For posterity and in case you're banging your head on the same thing, here's the solution.

Check your logs (tail -f <magento_root>/var/log/system.log).

If you have copied any XML from the web, view it in a text editor and ensure that you do not have invisible characters!

Does not work:

<config>
    <menu>
        <namespace module="namespace_package">
            <title>Namespace</title>
            <sort_order>200</sort_order>
                <children>
                    <overview>
                    <title>Overview</title>
                    <sort_order>1</sort_order>
                    <action>adminhtml/namespace/index</action>
                </overview>
            </children>
        </namespace>
    </menu>
    <acl>
     <resources>
        <admin>
            <children>
                <namespace module="namespace_package">
                    <title>Top Level Namespace Menu Item</title>
                    <sort_order>1</sort_order>
                </namespace>
                </children>
            </admin>
        </resources>
    </acl>
</config>

Solution: make sure your module defined for the <config><menu> in adminhtml.xml is correctly using ONLY the namespace and not Namespace_Package or namespace_package.

This works:

<config>
    <menu>
        <namespace module="namespace">
            <title>Namespace</title>
            <sort_order>200</sort_order>
                <children>
                    <overview>
                    <title>Overview</title>
                    <sort_order>1</sort_order>
                    <action>adminhtml/namespace/index</action>
                </overview>
            </children>
        </namespace>
    </menu>
    <acl>
     <resources>
        <admin>
            <children>
                <namespace module="namespace">
                    <title>Top Level Namespace Menu Item</title>
                    <sort_order>1</sort_order>
                </namespace>
                </children>
            </admin>
        </resources>
    </acl>
</config>
0

Your code from config.xml

<config>
<global>
    <helpers>
        <package>
            <class>Namespace_Package_Helper</class>
        </package>
    </helpers>
</global>

Your helper in /test.php

$helper = Mage::helper('package');

Your Answer

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

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