0

我是 PHP 和 Magento 的新手,我正在尝试从 Magento 中删除客户,但出现此错误 -

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

在其他时候我得到 -

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

CustomerController.php 文件包含此代码 -

<?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();
    }
}
4

2 回答 2

2

改变

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

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

然后重命名

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

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

然后通过编辑文件更改类名/app/code/local/Braintree/{Modulename}/Model/Paymentmethod.php

改变

  class Braintree_{Modulename}_Model_PaymentMethod ...

  class Braintree_{Modulename}_Model_Paymentmethod ...
于 2013-07-03T15:58:50.157 回答
0

you shall not use camel case class names like paymentMethod!

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

Rename your class to Paymentmethod.php, rename the class label inside the class file accordingly.

Then do a

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

if the result in the Mage::log is empty you made a mistake with you factory...

Good luck!

于 2013-07-03T13:36:43.520 回答