1

I am trying to make a module with some settings I can change via system configuration

they explained me here: How to make some parameters editable via admin

However I am having the following problem

Fatal error: Class 'Mage_Affiliate_Helper_Data' not found in /home/theprint/public_html/preprod/app/Mage.php on line 547

The structure is as follows:

Should I create a data.php empty?

http://screencast.com/t/mOnMlNKun

Update 1:

this is my config.xml

  <?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Luisvalencia_Affiliate>
            <version>0.0.1</version>
        </Luisvalencia_Affiliate>
    </modules>
    <global>
        <models>
            <luisvalencia_affiliate>
                <class>Luisvalencia_Affiliate_Model</class>
            </luisvalencia_affiliate>
        </models>
        <helpers>
            <luisvalencia_affiliate>
                <class>Luisvalencia_Affiliate_Helper</class>
            </luisvalencia_affiliate>
        </helpers>
    </global>
    <frontend>
        <events>
            <controller_action_predispatch>
                <observers>
                    <luisvalencia_affiliate>
                        <class>luisvalencia_affiliate/observer</class>
                        <method>captureReferral</method>
                        <type>singleton</type>
                    </luisvalencia_affiliate>
                </observers>
            </controller_action_predispatch>
        </events>
    </frontend>
</config>

3 Answers 3

0

As I see that your error is Class 'Mage_Affiliate_Helper_Data' not found that means helper name should be affiliate that means Mage::helper('affiliate'); and need to add this code in config.xml file

    ....
        <global>
....
<!-- add this code in global tag in  global -->
            <helpers>
                 <affiliate>
                       <class>Luisvalencia_Affiliate_Helper</class>
                 </affiliate>
            </helpers>
.....
        </global>

And Need to define helper class and helper file is Data.php(Luisvalencia/Affiliate/Helper/Data.php)

<?php 
class Luisvalencia_Affiliate_Helper_Data extends Mage_Core_Helper_Abstract {
}

Edit:According to your code

<helpers>
            <luisvalencia_affiliate>
                <class>Luisvalencia_Affiliate_Helper</class>
            </luisvalencia_affiliate>
        </helpers>

should be

 <helpers>
                 <affiliate>
                       <class>Luisvalencia_Affiliate_Helper</class>
                 </affiliate>
            </helpers>
5
  • who and why is given negative marks... i cannot understand .. there are two times, i got negative marks in other questions... can any one tell me what happen
    – Amit Bera
    Aug 14, 2014 at 18:03
  • I already did, and I still get Fatal error: Class 'Mage_Affiliate_Helper_Data' not found in /home/theprint/public_html/preprod/app/Mage.php on line 547 Aug 14, 2014 at 18:32
  • pls check screenshot, screencast.com/t/fnLn2zi52 Aug 14, 2014 at 18:33
  • it works, but then why my observer works without any problem! seems strange screencast.com/t/yjnXBb7SJW58 Aug 14, 2014 at 18:49
  • is getStoreConfig get proper value???
    – Amit Bera
    Aug 14, 2014 at 18:53
1

Yes you need to define your helper class. This includes two steps

Define helper class inside config.xml

<config>
    <global>
        <helpers>
             <luisvalencia_affiliate>
                   <class>Luisvalencia_Affiliate_Helper</class>
             </luisvalencia_affiliate>
        </helpers>
    </global>
</config>

Declare your Helper Class

location: app/code/community/Luisvalencia/Affiliate/Helper/Data.php

<?php 
class Luisvalencia_Affiliate_Helper_Data extends Mage_Core_Helper_Abstract {
}

Now you can refer you helper like this.

 Mage::helper('luisvalencia_affiliate');

Hope that helps

2
  • I updated my question, whats my missing piece on config? Aug 14, 2014 at 17:26
  • sorry, my answer was not aligned properly. Now you can see my code Aug 14, 2014 at 17:27
0

Yes. Create a Data.php file like

<?php class Luisvalencia_Affiliate_Helper_Data extends Mage_Core_Helper_Abstract {
}

and declare it in your module config too. This normally happens when you try to call __() to translate something.

Your Answer

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

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