donglingyi4679 2013-07-03 12:51
浏览 37
已采纳

致命错误:在非对象中调用成员函数deleteCustomer()

I'm new to PHP and Magento, I'm trying to delete a Customer from Magento and I get this error -

Fatal error: Call to a member function deleteCustomer() on a non-object in /home/c42gor/public_html/app/code/local/Braintree/controllers/CustomerController.php on line 30

At other times I get -

Fatal error: Call to a member function deleteCustomer() on a non-object in /home/c42gor/public_html/app/code/local/Braintree/controllers/CustomerController.php on line 15

The CustomerController.php file contains this code -

<?php

require('Mage/Adminhtml/controllers/CustomerController.php');

class Braintree_CustomerController extends Mage_Adminhtml_CustomerController
{

    public function deleteAction()
    {
        $braintree = Mage::getModel('braintree/paymentMethod');
        $customerId = $this->getRequest()->getParam('id');

        if ($customerId)
        {
            $braintree->deleteCustomer($customerId);
        }

        parent::deleteAction();
    }

    public function massDeleteAction()
   {
        $customerIds = $this->getRequest()->getParam('customer');

        if(is_array($customerIds))
        {
            $braintree = Mage::getModel('braintree/paymentMethod');
            foreach ($customerIds as $customerId)
            {
                $braintree->deleteCustomer($customerId);
            }
        }

        parent::massDeleteAction();
    }
}
  • 写回答

2条回答 默认 最新

  • douzhuanqian8244 2013-07-03 15:58
    关注

    Change

    $braintree = Mage::getModel('braintree/paymentMethod');
    

    To

    $braintree = Mage::getModel('braintree/paymentmethod');
    

    Then rename

    /app/code/local/Braintree/{Modulename}/Model/PaymentMethod.php
    

    To

     /app/code/local/Braintree/{Modulename}/Model/Paymentmethod.php
    

    Then change the class name by edit file /app/code/local/Braintree/{Modulename}/Model/Paymentmethod.php

    Change

      class Braintree_{Modulename}_Model_PaymentMethod ...
    

    To

      class Braintree_{Modulename}_Model_Paymentmethod ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解