0

My Config.xml

    <?xml version="1.0"?>  <config>
      <modules>
        <MyCompany_MyModule>
          <version>1.0.0</version>
        </MyCompany_MyModule>
     </modules>
     <global>
       <helpers>
          <mycompany_mymodule>
             <class>MyCompany_MyModule_Helper</class>
          </mycompany_mymodule>
       </helpers>
     </global>
   </config>

Path Helper

http\app\code\local\MyCompany\MyModule\Helper

File i want call

http\app\code\local\MyCompany\MyModule\Helper\Config.php

My Config.php Class

class MyCompany_MyModule_Helper_Config {}

My Class inside Model call Helper

http\app\code\local\MyCompany\MyModule\Model\Form\FileName.php

The Call

class MyCompany_MyModule_Model_Form_Input {
public function initializes()
{    
$helper = Mage::helper('MyCompany_MyModule/Config');
 Mage::Log($helper);
 } }

The Error

Warning: include(): Failed opening 'Mage/MyCompany/MyModule/Helper/Config.php' for inclusion 

My http\app\etc\modules\MyCompany_MyModule.xml

<?xml version="1.0"?> <config>
<modules>
    <MyCompany_MyModule>
        <active>true</active>
        <codePool>local</codePool>
    </MyCompany_MyModule>
</modules> </config>
15
  • is compilation enabled?
    – kunj
    Aug 7, 2018 at 10:39
  • yes it is enabled Aug 7, 2018 at 10:44
  • Is your config.xml code for helper is like this <global><helpers><mycompany_mymodule><class>MyCompany_MyModule_Helper</class></mycompany_mymodule></helpers></global>
    – kunj
    Aug 7, 2018 at 10:45
  • 1
    Please check file permission is that accessible for web server user? the code is perfect I have just created with same code in my local working fine so maybe issue with web server user permission.
    – kunj
    Aug 7, 2018 at 11:18
  • 1
    ok solved, deleting the files and recreating them, it was a problem of reading the files I do not know because the first time it had not worked, the code was all right. Aug 7, 2018 at 11:33

3 Answers 3

1

Try this:

you can load your custom helper MyCompany_MyModule_Helper_Config located in

app/code/local/MyCompany/MyModule/Helper/Config.php

$helper = Mage::helper('mycompany_mymodule/config');
1
  • Unfortunately it does not work: error Failed opening 'Mage/Mycompany/Mymodule/Helper/Config.php' Failed opening 'Mymodule.php' for inclusion Aug 7, 2018 at 10:41
1

Try after disabling compilation and flush cache confirm below code.

<global>
    <helpers>
        <mycompany_mymodule>
            <class>MyCompany_MyModule_Helper</class>
        </mycompany_mymodule>
    </helpers>
</global>

Also, need to confirm that Config.php file executable for web server user

you can call that by this Mage::helper('mycompany_mymodule/config');

4
  • Compilation: Disabled | Cache: Flush | Same Error: Warning: include(): Failed opening 'Mage/MyCompany/MyModule/Helper/Config.php' for inclusion Aug 7, 2018 at 10:53
  • @OrazioD'Arrigo, Please share your full extension. have you created module config file in app/etc/modules/ folder like this app/etc/modules/MyCompany_MyModule.xml
    – kunj
    Aug 7, 2018 at 10:57
  • have add up the module config Aug 7, 2018 at 11:01
  • @OrazioD'Arrigo, Are you calling that with this Mage::helper('mycompany_mymodule/config'); same code? I mean text must be 'mycompany_mymodule/config'
    – kunj
    Aug 7, 2018 at 11:27
0
  1. Rename your helper from

    app/code/local/MyCompany/MyModule/Helper/Config.php

    to

    app/code/local/MyCompany/MyModule/Helper/Data.php

  2. app/code/local/MyCompany/MyModule/Helper/Data.php:

    <?php
    class MyCompany_MyModule_Helper_Data extends Mage_Core_Helper_Abstract{
    
        public function workMyHelper() {
            return "It works now !";
        }
    }
    
  3. You call your helper function like this:

    Mage::helper('mycompany_mymodule')->workMyHelper();
    
5
  • The Data already exists, I wanted to create a specific file for the configurations. Aug 7, 2018 at 11:16
  • just add /config after mycompany_mymodule = Mage::helper('mycompany_mymodule/config')->workMyHelper(); if it doesn't work try to update config.php to myconfig.php and you call it like this : Mage::helper('mycompany_mymodule/myconfig')->workMyHelper();
    – PЯINCƎ
    Aug 7, 2018 at 11:21
  • return same error if i use Data Aug 7, 2018 at 11:27
  • Your module is well enabled ? check in app/etc/modules/MyCompany_MyModule.xml <?xml version="1.0"?> <config> <modules> <MyCompany_MyModule> <active>true</active> <codePool>local</codePool> </MyCompany_MyModule> </modules> </config>
    – PЯINCƎ
    Aug 7, 2018 at 11:40
  • Flush also the cache, clean the content of var/cache from your server
    – PЯINCƎ
    Aug 7, 2018 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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