这是错误消息: 致命错误:在第58行的C:\ wamp \ www \ magento \ app \ code \ core \ Mage \ Adminhtml \ Block \ Customer \ Edit \ Tabs.php中的非对象上调用成员函数initForm()
我复制这个文件: C:\ WAMP \ WWW \ Magento的\ APP \代码\核心\法师\ Adminhtml \块\用户\编辑\ Accounts.php 至: C:\瓦帕\ WWW \ Magento的\应用\代码\本地\ MY_PROJECT \ Adminhtml \块\客户\编辑\标签\ Accounts.php
然后只编辑这个函数:
<?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**/
这是Tabs.php第56-60行的代码
$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
));
我在这里要做的是删除帐户信息表中的姓名,邮政编码,国家/地区,性别等,只会留下电子邮件。
如果我在Core文件中执行所有这些操作,那一切都很顺利但是如果我尝试覆盖它并将其保存在本地文件夹中,则会出现此错误。
P.S。我还在本地添加了config.xml,并在名为My_Project_Adminhtml.xml的C:\ wamp \ www \ magento \ app \ etc \ modules中添加了一个xml
提前感谢任何有帮助的人。
这是我的config.xml保存在C:\ wamp \ www \ magento \ app \ code \ local \ My_Project \ Adminhtml \ etc
<?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>
这是我的模块xml保存在... / app / etc / modules文件夹
<?xml version="1.0" ?>
<config>
<modules>
<My_Project_Adminhtml>
<active>true</active>
<codePool>local</codePool>
</My_Project_Adminhtml>
</modules>
</config>
答案 0 :(得分:1)
如果您的配置文件布局与此相同,您可能需要删除类名周围的空白,以便它是节点中的唯一内容。
<adminhtml>
<rewrite>
<customer_edit_tab_account>My_Project_Adminhtml_Block_Customer_Edit_Tab_Account</customer_edit_tab_account>
</rewrite>
</adminhtml>
答案 1 :(得分:0)
确保所有XML文件都是正确的XML,我在2天前发生了完全相同的事情,因为我拼错了一个结束标记。如果这导致错误,您将在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: