Magento Error upon Overriding in local folder

This is the error message: Fatal error: Call to a member function initForm() on a non-object in C:wampwwwmagentoappcodecoreMageAdminhtmlBlockCustomerEditTabs.php on line 58

I copy this file: C:wampwwwmagentoappcodecoreMageAdminhtmlBlockCustomerEditAccounts.php to: C:wampwwwmagentoappcodelocalMy_ProjectAdminhtmlBlockCustomerEditTabAccounts.php

then edit only this function:

<?php

class My_Project_Adminhtml_Block_Customer_Edit_Tab_Account extends Mage_Adminhtml_Block_Customer_Edit_Tab_Account
{

    public function initForm()
    {   
        Mage::log('Debug1: _initForm was called',null,'globe.log');

        $form = new Varien_Data_Form();
        $form->setHtmlIdPrefix('_account');
        $form->setFieldNameSuffix('account');

        $customer = Mage::registry('current_customer');

        /* @var $customerForm Mage_Customer_Model_Form */
        $customerForm = Mage::getModel('customer/form');
        $customerForm->setEntity($customer)
            ->setFormCode('adminhtml_customer')
            ->initDefaultValues();

        $fieldset = $form->addFieldset('base_fieldset',
            array('legend'=>Mage::helper('customer')->__('Account Information'))
        );

        $attributes = $customerForm->getAttributes();

        //Start of edit//
        //Remove the Un-needed labels from the Customer Information Form
        //These are the codes that I added:

        unset($attributes['prefix']);
        unset($attributes['firstname']);
        unset($attributes['middlename']);
        unset($attributes['lastname']);
        unset($attributes['suffix']);
        unset($attributes['taxvat']);
        unset($attributes['dob']);
        unset($attributes['gender']);

        //End of edit//

        foreach ($attributes as $attribute) {
            $attribute->unsIsVisible();
        }
        $this->_setFieldset($attributes, $fieldset);

        /**Usual codes continues here**/

this are the codes on line 56-60 of Tabs.php

$this->addTab('account', array(
        'label'     => Mage::helper('customer')->__('Account Information'),
        'content'   => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_account')->initForm()->toHtml(),
        'active'    => Mage::registry('current_customer')->getId() ? false : true
    ));

What I want to do here is to remove the names, zip, country, gender, etc, in Account Information Form, only the email will remain.

If I do all of this in the Core files, It all went well but If I try to override this and save it in local folder, this error arises.

PS I also add the config.xml in my local, and add a xml in C:wampwwwmagentoappetcmodules named My_Project_Adminhtml.xml

Thanks In Advance for anyone that will help.

this is my config.xml save on C:wampwwwmagentoappcodelocalMy_ProjectAdminhtmletc

    <?xml version="1.0" ?>
<config>
    <modules>
        <My_Project_Adminhtml>
            <version>1.0</version>
        </My_Project_Adminhtml>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <customer_edit_tab_account>
                        My_Project_Adminhtml_Block_Customer_Edit_Tab_Account
                    </customer_edit_tab_account>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>

this is my module xml save on .../app/etc/modules folder

    <?xml version="1.0" ?>
<config>
    <modules>
        <My_Project_Adminhtml>
            <active>true</active>
            <codePool>local</codePool>
        </My_Project_Adminhtml>
    </modules>
</config>

如果你的配置文件布局与此相同,你可能需要删除类名周围的空白,这样它才是节点中唯一的东西。

<adminhtml>
    <rewrite>
        <customer_edit_tab_account>My_Project_Adminhtml_Block_Customer_Edit_Tab_Account</customer_edit_tab_account>
    </rewrite>
</adminhtml>

Ensure all of your XML files are correct XML, I had exactly the same thing occur 2 days ago, because I had misspelled a closing tag. If this is causing the error, you will something like the following in your system.log

2012-01-23T04:40:31+00:00 ERR (3): Warning: simplexml_load_string(): Entity: line 56: parser error : Opening and ending tag mismatch: 
链接地址: http://www.djcxy.com/p/65178.html

上一篇: 在magento 1.7中按客户组排序

下一篇: 在本地文件夹中覆盖时发生Magento错误