Magento 1.4.2:保存自定义客户属性时出错

Magento 1.4.2:保存自定义客户属性时出错,magento,Magento,我无法保存我的自定义客户属性: 我的Magento后端被阻止,出现以下错误: 2011-08-03T12:27:36+00:00 ERR (3): Warning: include(Mage\Customer\Model\Attribute\Data\.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in C:

我无法保存我的自定义客户属性:

我的Magento后端被阻止,出现以下错误:

2011-08-03T12:27:36+00:00 ERR (3): Warning: include(Mage\Customer\Model\Attribute\Data\.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory  in C:\xampp\htdocs\magento_test142_3\lib\Varien\Autoload.php on line 93

2011-08-03T12:27:36+00:00 ERR (3): Warning: include() [<a href='function.include'>function.include</a>]: Failed opening 'Mage\Customer\Model\Attribute\Data\.php' for inclusion (include_path='C:\xampp\htdocs\magento_test142_3\app\code\local;C:\xampp\htdocs\magento_test142_3\app\code\community;C:\xampp\htdocs\magento_test142_3\app\code\core;C:\xampp\htdocs\magento_test142_3\lib;.;C:\xampp\php\PEAR')  in C:\xampp\htdocs\magento_test142_3\lib\Varien\Autoload.php on line 93
如果有人帮我解决这个真正的问题,那将非常有帮助


[/edit]

在安装脚本中删除此部分

Mage::getSingleton( 'eav/config' )
->getAttribute( 'customer', 'kd_nr' )
->setData( 'used_in_forms', array( 'adminhtml_customer' ) )
->save();
要调用eav_设置,请执行以下操作

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
然后您可以像这样更新属性:

$setup->updateAttribute ($entityTypeId,$id,$field,$value = null,$sortOrder=null)
您可以在此处获得可以调用的方法列表:

因此,我认为您的代码将替换为:

$setup->updateAttribute('customer', 'kd_nr', 'used_in_forms', 'adminhtml_customer');

在安装脚本中删除此部分

Mage::getSingleton( 'eav/config' )
->getAttribute( 'customer', 'kd_nr' )
->setData( 'used_in_forms', array( 'adminhtml_customer' ) )
->save();
要调用eav_设置,请执行以下操作

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
然后您可以像这样更新属性:

$setup->updateAttribute ($entityTypeId,$id,$field,$value = null,$sortOrder=null)
您可以在此处获得可以调用的方法列表:

因此,我认为您的代码将替换为:

$setup->updateAttribute('customer', 'kd_nr', 'used_in_forms', 'adminhtml_customer');

好吧,如果上面这些根本不起作用。。。我想让我们回到您的原始脚本,我想我可以找到一些修复:

    <?php
$installer=new  Mage_Customer_Model_Entity_Setup ('core_setup');
$installer->startSetup();

$installer->addAttribute('customer', 'kd_nr', array(
    'label'           => 'Kundennummer',
    'is_visible'      => 1,
    'is_required'     => 0,
    'sort_order'      => 20,
   ));   

    $attr = Mage::getSingleton( 'eav/config' )->getAttribute( 'customer', 'kd_nr' );
$attr->setData( 'used_in_forms', array( 'adminhtml_customer' ) )
$attr->save();

$installer->endSetup();

如果上述方法根本不起作用,那么可以。。。我想让我们回到您的原始脚本,我想我可以找到一些修复:

    <?php
$installer=new  Mage_Customer_Model_Entity_Setup ('core_setup');
$installer->startSetup();

$installer->addAttribute('customer', 'kd_nr', array(
    'label'           => 'Kundennummer',
    'is_visible'      => 1,
    'is_required'     => 0,
    'sort_order'      => 20,
   ));   

    $attr = Mage::getSingleton( 'eav/config' )->getAttribute( 'customer', 'kd_nr' );
$attr->setData( 'used_in_forms', array( 'adminhtml_customer' ) )
$attr->save();

$installer->endSetup();


看起来您在这里遇到了更深层次的问题。注意它试图加载的类文件。如果您注意到,文件名是“.php”。如果没有更多的诊断信息,就有点难以确定实际问题。感谢Lee Saferite,我终于想在Magento 1.4.2中添加自定义客户属性。这是我的最终目的,谢谢你的帮助。我认为你不能做Mage::getSingleton('eav/config')。。。在升级或安装脚本中?如果您需要设置或更新列,请使用脚本进行设置。您可以转到db table:eav_属性并按属性代码搜索您的属性,查看前端_输入是否设置为select,标签和模型是否正确声明。此外,如果缓存已清除。是的,我的属性有一个select in frontend_输入字段和eav/entity_属性_source_布尔值作为模型,entity_type_id=1(对于客户)!缓存当然是未激活的。谢谢。看来你有更深层次的问题。注意它试图加载的类文件。如果您注意到,文件名是“.php”。如果没有更多的诊断信息,就有点难以确定实际问题。感谢Lee Saferite,我终于想在Magento 1.4.2中添加自定义客户属性。这是我的最终目的,谢谢你的帮助。我认为你不能做Mage::getSingleton('eav/config')。。。在升级或安装脚本中?如果您需要设置或更新列,请使用脚本进行设置。您可以转到db table:eav_属性并按属性代码搜索您的属性,查看前端_输入是否设置为select,标签和模型是否正确声明。此外,如果缓存已清除。是的,我的属性有一个select in frontend_输入字段和eav/entity_属性_source_布尔值作为模型,entity_type_id=1(对于客户)!缓存当然是未激活的。谢谢。我已经在一个新的Magento安装中安装了这个新脚本,它在后端不显示我的属性!它似乎需要$setup->updateAttribute('customer','kd_nr','used_in_forms',array('adminhtml_customer');我使用'is_visible'=>true而不是'visible'=>true;尝试使用“后端\u模型”、“后端\u类型”和“后端\u表”。。。在较新版本的magento中,我想您可能需要其中一个来实际判断该属性是否在后端可见。好的,这似乎对我有效,将“frontend_input”设置为“text”,并将标签设置为像“frontend_label”一样的“Kundennummer”。。。这是误导,因为它有一个前端前缀。。。但是对我有用。如果这不起作用,那么添加'eav/entity_attribute_frontend_text',因为你的frontend_模型总是不适合我:(你能复制并粘贴文件“mysql4-install-0.1.0.php”的所有内容吗?非常感谢。我已经在一个新的Magento安装中安装了这个新脚本,它在后端没有显示我的属性!它似乎需要$setup->updateAttribute('customer','kd_nr','used_in_forms',array('adminhtml_customer'));我使用'is_visible'=>true而不是'visible'=>true;尝试在较新版本的magento中使用'backend_model'、'backend_type'和'backend_table'…我猜您可能需要其中一个来判断属性是否应该在后端可见。好的,这似乎对我有用,将'frontend_input'设置为'text',并将标签设置为你的“Kundennummer”中的“frontend_label”……这是误导性的,因为它有一个frontend前缀……但对我有效。如果不起作用,那么添加“eav/entity_attribute_frontend_text”,因为你的frontend_模型总是对我无效:(你能复制并粘贴文件“mysql4-install-0.1.0.php”的所有内容吗?非常感谢。请看一下我在原始帖子中的[edit]部分。我不确定如果这些工作不起作用,上面的代码可能会出现一些愚蠢的错误。我不知道问题出在哪里,但问题出在布尔“是/否”列表框中,我已经在我的问题[edit]中编写了代码。谢谢。请查看我的[edit]我不确定如果以上这些工作不起作用,可能是代码中的一些愚蠢错误,我猜?我不知道问题出在哪里,但问题出在布尔“是/否”列表框中,我已经在我的问题[edit]中编写了代码。谢谢。