Extending Community Extensions – Helper/Data.php in Magento

extensionshelper

I'm planning to extend a community extension by creating relevant files in app/code/local/myname/myext. The community extension has multiple files that I want to customise but let's start simply. How would I implement the local equivalent of Helper/Data.php, even just to show it's working?

For example the community extension is like

class Compasser_Diogenes_Helper_Data extends Mage_Payment_Helper_Data
{
    //
    public function startDiogenes($cId, $stId, $shId, $mCode)
    {
        // working code is here, can output to log files

My local file is just trying to prove it's getting called. app/code/local/Kaska/Diogenesext/Helper/Data.php

include_once 'Compasser/Diogenes/Helper/Data.php';
// I also tried require_once Mage::getConfig()->getModuleDir('Helper', 'Diogenes') . '/Data.php';

class Kaska_Diogenesext_Helper_Data extends Compasser_Diogenes_Helper_Data
{

    public function startDiogenes($cId, $stId, $shId, $mCode)
    {

        Mage::log('test', null, 'test.log');

This is app/code/local/Kaska/Diogenesext/etc/config.xml

<?xml version="1.0"?>
<config>
<modules>
    <Kaska_Diogenesext>
        <version>0.0.1</version>
    </Kaska_Diogenesext>
</modules>
<global>
    <helpers>
        <kaska_diogenesext>
            <rewrite>
                <data>Kaska_Diogenesext_Helper</data>
            </rewrite>
        </kaska_diogenesext>
    </helpers>

This is the what's in the app/etc/modules/Kaska_Diogenesext.xml file. It's showing as enabled in admin.

<?xml version="1.0"?>
<config>
<modules>
    <Kaska_Diogenesext>
        <active>true</active>
        <codePool>local</codePool>
        <depends>
            <Compasser_Diogenes></Compasser_Diogenes>
        </depends>
    </Kaska_Diogenesext>
</modules>

In my log files I just see the community extension working, there's nothing from the local extension, nothing in test.log and no errors either. Cache not enabled but flushed anyway.

Best Answer

There is no need to include the helper from Compasser because helpers are autoloaded (you have to include only controllers if you like to extend them). Also in your config.xml please try to change <kaska_diogenesext> to <compasser_diogenes> and <data>Kaska_Diogenesext_Helper</data> to <data>Kaska_Diogenesext_Helper_Data</data>.

Related Topic