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

0

paymentMethod のようなキャメル ケースのクラス名を使用しないでください。

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

クラスの名前を Paymentmethod.php に変更し、それに応じてクラス ファイル内のクラス ラベルの名前を変更します。

次に、

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

Mage::log の結果が空の場合は、工場で間違いを犯しています...

幸運を!

于 2013-07-03T13:36:43.520 に答える