Magento Fatal Error: Call to getMethodInstance() on Boolean – Fix

magento-1.9patches

I installed magento patches(7405,8788,6788) to site,after that when clicking on admin sales > order >view getting error like

   Fatal error: Call to a member function getMethodInstance() on boolean in /var/www/html/rmcstore/app/code/core/Mage/Sales/Model/Order.php

how to solve this

Best Answer

Even with very little PHP knowledge, you can always diagnose issues thanks to Magento's error reporting mechanism.

This error indicates the exact file & line of code which are responsible for it, so take the following steps:

  1. Navigate through app/code/core/Mage/Payment/Model/ & open Observer.php,
  2. Scroll to line 46

The line of code in 1.7 reads as follows:

if ($order->getPayment()->getMethodInstance()->getCode() != 'free') {

Now, the error message also tells you that the following code is what is causing the issue:

Call to a member function getMethodInstance()

So after you read the line of code on line 46, you'll see that that method is applied to the $order object, this is defined just above line 46 (on line 44):

$order = $observer->getEvent()->getOrder();
Related Topic