Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Fatal error: Call to a member function setMethod() on a non-object in /app/code/core/Mage/Payment/Helper/Data.php on line 133
 
Stanley Lim
Jr. Member
 
Total Posts:  8
Joined:  2008-10-25
 

Dear All,

First I’ll like to thanks Andrej for creating this great Bank Prepayment module! It’s available here: http://www.magentocommerce.com/extension/304/bank-prepayment-vorkasse- . However, the fields in his module are not very relevant in my area and I decide to futher modify the module to fit my needs.

I’m successful in adding the fields i need and removing those that I don’t. Now, I decided to change the name of the module so that it can co-exist with the orginal module written by Andrej. But I’m ecountering a php error which I have been poundering for few days… I’m getting this error whenever a user tries to checkout from his shopping cart.

Fatal error: Call to a member function setMethod() on a non-object in /var/www/GuangGuangJ.com/dev/app/code/core/Mage/Payment/Helper/Data.php on line 133

Here are the codes:
app/etc/modules/Mage_SGBankPayment.xml

<config>
    <
modules>
        <
Mage_SGBankPayment>
            <
active>true</active>
            <
codePool>community</codePool>
            <
depends>
                <
Mage_Payment />
            </
depends>
            <
version>0.0.1</version>
        </
Mage_SGBankPayment>
    </
modules>
</
config>

app/locale/en_US/Mage_SGBankPayment.csv

Bank Prepayment,Bank Prepayment
Pay within X days
,Pay within X days
Please transfer the money within 
%s days to the following bank account,Please transfer the money within %s days to the following bank account
Please transfer the money to the following bank account
,Please transfer the money to the following bank account
Account holder
,Account holder
Account number
,Account number
Bank code
,Bank code
Bank name
,Bank name
For international transfers please use also following data,For international transfers please use also following data
Branch code
,Branch code
Branch name
,Branch name
Account info
,Account info
International
,International
Custom text
,Custom text

app/code/community/Mage/SGBankPayment/etc/config.xml

<?xml version="1.0"?>
<config>
    <global>
        <
models>
            <
sgbankpayment>
                <class>
Mage_SGBankPayment_Model</class>
            </
sgbankpayment>
        </
models>

        <
resources>
            <
sgbankpayment_setup>
                <
setup>
                    <
module>Mage_SGBankPayment</module>
                </
setup>
                <
connection>
                    <use>
core_setup</use>
                </
connection>
            </
sgbankpayment_setup>
            <
sgbankpayment_write>
                <use>
core_write</use>
            </
sgbankpayment_write>
            <
sgbankpayment_read>
                <use>
core_read</use>
            </
sgbankpayment_read>
        </
resources>
    </global>

    <default>
        <
payment>
            <
sgbankpayment>
                <
active>1</active>
                <
model>sgbankpayment/sgBankPayment</model>
                <
order_status>1</order_status>
                <
title>Bank Prepayment</title>
                <
allowspecific>0</allowspecific>
            </
sgbankpayment>
         </
payment>
    </default>

    <
adminhtml>       
        <
translate>
            <
modules>
                <
Mage_SGBankPayment>
                    <
files>
                        <default>
Mage_SGBankPayment.csv</default>
                    </
files>
                </
Mage_SGBankPayment>
            </
modules>
        </
translate>
    </
adminhtml>
 
    <
frontend>       
        <
translate>
            <
modules>
                <
Mage_SGBankPayment>
                    <
files>
                        <default>
Mage_SGBankPayment.csv</default>
                    </
files>
                </
Mage_SGBankPayment>
            </
modules>
        </
translate>        
    </
frontend
</
config>

continue on next post…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Stanley Lim
Jr. Member
 
Total Posts:  8
Joined:  2008-10-25
 

Sorry pple. I’m not able to direct past my code due to the char limit.. I have attached the files anyway. Any kind soul can help me to see what have I done wrong? Thanks

File Attachments
SGBankPayment.zip  (File Size: 8KB - Downloads: 146)
 
Magento Community Magento Community
Magento Community
Magento Community
 
Stanley Lim
Jr. Member
 
Total Posts:  8
Joined:  2008-10-25
 

I have also found that if I comment out these 2 lines:

protected $_formBlockType 'sgbankpayment/form';
    protected 
$_infoBlockType 'sgbankpayment/info';

The error will disappear. But when the user reach the part where they have to choose the payment method, there is nothing displayed on it.... I suspect it something to do with my templates....

I’m running Magento 1.1.8 and using a self customed blank theme. Thanks in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Algiasa
Jr. Member
 
Total Posts:  12
Joined:  2009-01-19
 

Like you I’m poking around in the dark, but I had that exact same error and both times it was due to an error in my config.xml and system.xml files.

Now I could very well be completely wrong, but I have the impression you’re trying to use a block without having set it up in your config.xml.
Under <config><global> try adding:

<blocks>
<sgbankpayment>
<class>Mage_SGBankPayment_Block</class>
</sgbankpayment>
</blocks>

and let us know if it works out.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

@Standley Lim
I am also trying to modify Andrej extension and encountered exactly the same fatal error.

@Algiasa
I added the block declaration but it doesn’t help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
David Sedeño
Jr. Member
 
Total Posts:  20
Joined:  2008-09-25
 

Have you solve this issue? I have the same problem and didn’t found a solution.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
David Sedeño
Jr. Member
 
Total Posts:  20
Joined:  2008-09-25
 

Solved: As @Algiasa note, you must declare the blocks in etc/config.xml

 
Magento Community Magento Community
Magento Community
Magento Community
 
Finn
Member
 
Total Posts:  75
Joined:  2008-12-03
Finland & The Netherlands
 

Thanks Algiasa and Stanley Lim, your notes saved my day!

I was lacking the <blocks> code in my config.xml and I was having a case inconsistency in my Model/BankPayment.php which I noticed after Lim’s post, probably caused by a find-and-replace typo of mine, what should have been bankpayment was written as bankPayment. After changing it over everything seems to work as it should :D

By the way, could it be that changing the namespace from “Mage” to “MyNameSpace” prevent the autoload from finding the correct block class? It seems like a valid reason why to add <blocks> to the config.xml…

 
Magento Community Magento Community
Magento Community
Magento Community
 
guillaume7684
Sr. Member
 
Total Posts:  241
Joined:  2008-10-20
 

Hello,

I have the same problem and this solution doesn’t work for me.

I atteched all my files, could you help me, please.

I tried during 2 days and I don’t find the solution.

The module is displayed in the backoffice but when I want to pay my order in the frontend I have this message:

Fatal error: Call to a member function setMethod() on a non-object in /home/sygma/www/app/code/core/Mage/Payment/Helper/Data.php on line 133

Thank you so much.

Guillaume.

File Attachments
app.zip  (File Size: 6KB - Downloads: 95)
 
Magento Community Magento Community
Magento Community
Magento Community
 
vishal_2811
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2011-04-17
 

Hi All,

I am also having the same problem but it behaves in a strange way, When I am NOT loggedin and adds a product into my cart uptil here its fine BUT as I click on “Proceed to Checkout” it throws this error. Now on the other hand if I am loggedin in advance and do the same process, the order is placed successfully.
I have checked the Exception log and it says

2012-02-03T08:14:45+00:00 ERR (3): 
exception 'Mage_Core_Exception' with message 'Invalid block type: Mage_Page_Block_Html_Currencyheader' in /backup/ons/projects/yes2shop.pbodev.info/code/app/Mage.php:550
Stack trace
:
#0 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Model/Layout.php(469): Mage::throwException('Invalid block t...')
#1 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Model/Layout.php(411): Mage_Core_Model_Layout->_getBlockInstance('page/html_curre...', Array)
#2 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Model/Layout.php(446): Mage_Core_Model_Layout->createBlock('page/html_curre...', 'currencyhearder')
#3 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Model/Layout.php(238): Mage_Core_Model_Layout->addBlock('page/html_curre...', 'currencyhearder')
#4 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Model/Layout.php(204): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#5 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#6 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Controller/Varien/Action.php(343): Mage_Core_Model_Layout->generateBlocks()
#7 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Controller/Varien/Action.php(270): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#8 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Checkout/controllers/OnepageController.php(165): Mage_Core_Controller_Varien_Action->loadLayout()
#9 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Checkout_OnepageController->indexAction()
#10 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(253): Mage_Core_Controller_Varien_Action->dispatch('index')
#11 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#12 /backup/ons/projects/yes2shop.pbodev.info/code/app/code/core/Mage/Core/Model/App.php(340): Mage_Core_Controller_Varien_Front->dispatch()
#13 /backup/ons/projects/yes2shop.pbodev.info/code/app/Mage.php(627): Mage_Core_Model_App->run(Array)
#14 /backup/ons/projects/yes2shop.pbodev.info/code/index.php(80): Mage::run('', 'store')
#15 {main}
The whole file is attached due to the restrictions of character limits into the post.
You can try it @ Yes2Shop

Please help me in this.

Thanks.

File Attachments
exception.log  (File Size: 18KB - Downloads: 74)
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top