4

Is it possible to create a module/extension with only a Helper class declared? I am trying to create a module because I need to use a function on more than one phtml files.

So far I got this code:

/app/etc/modules/Mycompanyname_CategoryStep.xml

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

/app/code/local/Mycompanyname/CategoryStep/Helper/Data.php

<?php
class Mycompanyname_CategoryStep_Helper_Data extends Mage_Core_Helper_Abstract
{
    public function add($num1, $num2)
    {
        return $num1 + $num2;
    }
}

/app/code/local/Mycompanyname/CategoryStep/etc/config.xml

<?xml version="1.0" encoding ="UTF-8"?>
<config>
    <modules>
        <Mycompanyname_CategoryStep>
        <version>0.1.0</version>
        </Mycompanyname_CategoryStep>
    </modules>
    <global>
        <helpers>
            <categorystep>
                <class>Mycompanyname_CategoryStep_Helper</class>
            </categorystep>
        </helpers>
    </global>
</config>

That's the error I get:

Fatal error: Class 'Mage_Categorystep_Helper_Data' not found in /home/account/public_html/app/Mage.php on line 550

Am I missing something? I followed this guide to create the module and this guide and several others to create the Helper class. Any help would be appreciated.

2
  • 1
    Looks like you have done spelling mistake or there some issues with upper and lower case char linux is case sensitive so check spelling and lower and upper case character is properly used.
    – Aman Alam
    Aug 6, 2019 at 7:01
  • 1
    Good to hear that you have resolved your issue. +1 for answer acceptance :) Aug 6, 2019 at 7:17

1 Answer 1

1

Yes you can. You need to create module xml in

in app/etc/modules/Mycompanyname_Categorystep.xml

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

Then for module main config create app/code/local/Mycompanyname/Categorystep/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Mycompanyname_Categorystep>
      <version>0.1.0</version>
    </Mycompanyname_Categorystep>
  </modules>
  <global>
    <helpers>
      <categorystep>
        <class>Mycompanyname_Categorystep_Helper</class>
      </categorystep>
    </helpers>
  </global>
</config> 

then your helper app/code/local/Mycompanyname/Categorystep/Helper/Data.php

<?php
class Mycompanyname_Categorystep_Helper_Data extends Mage_Core_Helper_Abstract
{
    //Your code here
}

The thing is, in Magento 1.9 module name's first letter should capital, but not all other. So you need to use Categorystep instead of CategoryStep

1
  • 1
    That was driving me crazy! Thank you for your help. It is indeed working fine now.
    – Nomik
    Aug 6, 2019 at 7:16

Your Answer

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

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