0

NOTE: This appears to be compiler related. Disabling and clearing compiler code appears to have worked to get this doing what it was supposed to.

So this one is a bit odd. I'm sure it's old hat to some now, and I've just done a bad job searching it out. If that's the case I certainly apologize and ask for your indulgence and a link to the already provided answer.

So I have followed the core guides for creating a magento module, but for some reason it does work right. When I var_dump the helper class it has the correct name, but when I try to use one of the methods I've put in the class definition it throws an exception.

Furthermore, when I run get_class_methods() on the class given to me by Mage::helper('mymodule/myhelper') none of my methods are there.

So in summary:

  1. The class is in the right place, app/code/local/MyModule/Helper/Myhelper.php
  2. The class shows as initialized after I call Mage::helper('mymodule/myhelper')
  3. The class methods are not listed, and as a result, break things when called.

Here's my config for reference. The rest of the module seems to be fine.

<?xml version="1.0"?>

<config>
  <modules>
    <APCShared_Shipping>
      <version>0.1.0</version>
    </APCShared_Shipping>
  </modules>
  <frontend>
    <routers>
      <apcshipping>
        <use>standard</use>
        <args>
          <module>APCShared_Shipping</module>
          <frontName>apcshipping</frontName>
        </args>
      </apcshipping>
    </routers>
  </frontend>
  <global>
    <blocks>
      <apcshipping>
        <class>APCShared_Shipping_Block</class>
      </apcshipping>
    </blocks>
    <helpers>
      <apcshipping>
        <class>APCShared_Shipping_Helper</class>
      </apcshipping>
    </helpers>
    <models>
      <apcshipping>
        <class>APCShared_Shipping_Model</class>
        <resourceModel>shipping_resource</resourceModel>
      </apcshipping>
      <apcshipping_resource>
        <class>APCShared_Shipping_Model_Resource</class>
        <entities>
          <zipcode>
            <table>apc_shipping_zipcode</table>
          </zipcode>
        </entities>
      </apcshipping_resource>
    </models>
  </global>
</config>
  • Could you please update your examples with real code as mymodule/myhelper does not match your config. – Kristof at Fooman Dec 21 '13 at 2:56
  • So, sorry about the big todo, but it appears that this was compiler related. – Joe Mills Dec 21 '13 at 4:27
  • The path of the file should be app/code/local/APCShared/Shipping/Helper/Myhelper.php it seems you forgot the namespace directory just above your extension directory – Sander Mangel Dec 21 '13 at 8:42
1

You can try below ones

If your module is created perfectly and you have methods in myhelper.php file look as below.

class Namespace_ModuleName_Helper_Myhelper extends Mage_Core_Helper_Abstract
{
public function getModuleStatus()
    {                
       return 'testing';
    }
}

to access the getModuleStatus() method in any phtml of php file then you can use

<?php echo Mage::helper('mymodule')->getModuleStatus();?>

you defiantly got the value as a "testing".

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.