开发者

Magento-module renamed, but Magento keeps asking for the old helper class

开发者 https://www.devze.com 2023-03-15 04:04 出处:网络
Magento, versions CE 1.4.2, 1.5.0.1, 1.5.1.0 I have had to adapt a payment module for Magento, following all recipes, config.xml, system.xml, etc/module/Mycompany_Mypaymentmodule.xml, which all work

Magento, versions CE 1.4.2, 1.5.0.1, 1.5.1.0

I have had to adapt a payment module for Magento, following all recipes, config.xml, system.xml, etc/module/Mycompany_Mypaymentmodule.xml, which all work fine.

But recently, I've double checked and found an error: in my config.xml, I had put:

<config>
<modules>
    <Mage_Mycompany>
        <version>0.1.0</version>
    </Mage_Mycompany>
</modules>

...

That's because originally, the module was supposed to be placed inside the community-folder.

Following the guidelines, I've rewritten classes, xml's et cetera to reflect the local codepool. That too went well (except for an error that I had debugged).

However, inside the config.xml, I have renamed the modules-tag, like so:

<config>
    <modules>
        <Mycompany_Mypaymentmodule>
        <version>0.1.0</version>
        </Mycompany_Mypaymentmodule>
</modules>

The strange thing is that Magento now keeps asking me for the old Helper-class-file when I go to the Payment Methods in the backend, resulting in:

Fatal error: Class 'Mage_Mycompany_Helper_Data' not found in path\to\app\Mage.php on line 520

In other words, Magento keeps asking for a helper class of my old, pre-renamed module, which of course is nowhere to be found.

I've done an extensive search in all files, but nowhere is the string Mage_Mycompany to be found, so my guess is Magento is trying to load this helper class out of a database table. Of course, I've cleared the cache and rebuilt all indexes multiple times, and removed all cache files. I also checked practically all database tables, but to no avail.

Second, when I create the helper class by hand in app/code/community/Mage/Mycompany/Helper/Data.php, all goes well, which to me sounds strange, because the class itself should not be called (since it is never mentioned in any co开发者_StackOverflow中文版nfig.xml).

I must be missing something, and perhaps the class name is generated on the fly, but I really do not know how to avoid it or to fix it... so any help is appreciated!


Step one, of course, is to clear your cache.

If clearing cache doesn't work.

Step 2: The data helper class is used to translate strings for a module. That is, each data helper has a method

$helper->__('Translate this symbol');

that will translate a string per that module's helper file.

Throughout the system, there are several XML files where you may want certain nodes to be translated. The syntax looks something like this.

<dhl translate="label" module="usa">
    <label>The Label</label>
</dhl>

Here you're telling magento to translate the "label" node enclosed in dhl, and to use the usa module to do it. That is, use the helper instantiated like

$Mage::getModel('usa/data');
//same thing as above, helpers default to data
Mage::getModel('usa');

to translate the label

$helper->__('The Label');

My guess is one of your XML files still has your old module configure for translation

<sometag module="mycompany" translate="someothertag" />

which makes magento look for a helper that's no longer there, and boom, there's your error.


Tha Data helper is loaded when you call the translation helper, ie: Mage::helper('modulename')->__("some string to translate").
In your config .xml, have you declared the module's helper class?:

<config>
    ...
    <global>
        ...
        <helpers>
            <yourmodule>
                <class>Yourcompanyname_Yourmodule_Helper</class>
            </yourmodule>
        </helpers>
        ...
    </global>
    ...
</config>
0

精彩评论

暂无评论...
验证码 换一张
取 消