我对Magento 1.9客户导出本机功能有疑问。当我要导出客户时,出现此错误:
致命错误:未被捕获的错误:在第201行的... \ app \ code \ core \ Mage \ ImportExport \ Model \ Export \ Entity \ Customer.php中调用null上的成员函数getFrontendInput()
此行是:if ($addressAttribute->getFrontendInput() == 'multiselect') {...}
调试代码后,我发现问题是因为我为customer_address类型创建了一些自定义属性。
也许我没有正确创建,这是我的安装程序:
$installer = $this;
$installer->startSetup();
$forms = array(
'customer_register_address',
'customer_address_edit',
'adminhtml_customer_address'
);
/**
* Create customer_cnp attribute
*/
$installer->addAttribute('customer_address', 'blugento_customer_cnp', array(
'type' => 'varchar',
'input' => 'text',
'label' => 'CNP',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'visible_on_front' => 1
));
Mage::getSingleton('eav/config')
->getAttribute('customer_address', 'blugento_customer_cnp')
->setData('used_in_forms', $forms)
->save();
/**
* Create customer_reg_no attribute
*/
$installer->addAttribute('customer_address', 'blugento_customer_reg_no', array(
'type' => 'varchar',
'input' => 'text',
'label' => 'Company Registration Number',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'visible_on_front' => 1
));
Mage::getSingleton('eav/config')
->getAttribute('customer_address', 'blugento_customer_reg_no')
->setData('used_in_forms', $forms)
->save();
/**
* Create customer_iban attribute
*/
$installer->addAttribute('customer_address', 'blugento_customer_iban', array(
'type' => 'varchar',
'input' => 'text',
'label' => 'IBAN',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'visible_on_front' => 1
));
Mage::getSingleton('eav/config')
->getAttribute('customer_address', 'blugento_customer_iban')
->setData('used_in_forms', $forms)
->save();
/**
* Create customer_bank attribute
*/
$installer->addAttribute('customer_address', 'blugento_customer_bank', array(
'type' => 'varchar',
'input' => 'text',
'label' => 'Bank Name',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'visible_on_front' => 1
));
Mage::getSingleton('eav/config')
->getAttribute('customer_address', 'blugento_customer_bank')
->setData('used_in_forms', $forms)
->save();
/**
* Add columns for new attributes in sales_flat_order_address and
sales_flat_quote_address
*/
$tableQuote = $this->getTable('sales/quote_address');
$installer->run("ALTER TABLE $tableQuote ADD `blugento_customer_cnp` VARCHAR(150) NULL DEFAULT NULL");
$installer->run("ALTER TABLE $tableQuote ADD `blugento_customer_reg_no` VARCHAR(150) NULL DEFAULT NULL");
$installer->run("ALTER TABLE $tableQuote ADD `blugento_customer_iban` VARCHAR(150) NULL DEFAULT NULL");
$installer->run("ALTER TABLE $tableQuote ADD `blugento_customer_bank` VARCHAR(150) NULL DEFAULT NULL");
$tableQuote = $this->getTable('sales/order_address');
$installer->run("ALTER TABLE $tableQuote ADD `blugento_customer_cnp` VARCHAR(150) NULL DEFAULT NULL");
$installer->run("ALTER TABLE $tableQuote ADD `blugento_customer_reg_no` VARCHAR(150) NULL DEFAULT NULL");
$installer->run("ALTER TABLE $tableQuote ADD `blugento_customer_iban` VARCHAR(150) NULL DEFAULT NULL");
$installer->run("ALTER TABLE $tableQuote ADD `blugento_customer_bank` VARCHAR(150) NULL DEFAULT NULL");
$installer->endSetup();
经过更多调试后,我发现如果我的客户都没有完成这些新的地址属性,则导出工作正常,因此只有在这些属性的值均已完成的情况下,我才报错。
谁能告诉我我在做什么错?谢谢!