I have implemented a third party api and I am getting bellow error:

Fatal error: Call to a member function getMethod() on a non-object in /var/www/html/app/code/local/Openpay/Banks/Model/Observer.php on line 14

at line 14 I have below code:

if(Mage::getConfig()->getModuleConfig('Openpay_Banks')->is('active', 'true')){
    $order_ids_list = $order_ids->getOrderIds();
    $order_id  = $order_ids_list[0];
    $order = Mage::getModel('sales/order')->load($order_id);

    $code = Mage::getModel('Openpay_Banks_Model_Method_Banks')->getCode();

    if($order->getPayment()->getMethod() == $code){
        $args = array(
            'order' => $order->getIncrementId(),
            'id' => $order->getPayment()->getOpenpayPaymentId(),

        $this->_redirect('print', 'payments', $code, $args);

what I can do to fix this error?

1 Answer 1


I found that when I used below code

$order_id = array_pop( $order_ids_list);

it return null value, I don't know why, so in order to fix that I store the value of array in another keys variable and then access keys variable to pass the orderId value in order variable.

$keys = array_keys($order_ids_list);
$order = Mage::getModel('sales/order')->load($keys[0]);

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.