Magento 1.4.2: ошибки при сохранении пользовательских атрибутов клиента - PullRequest
1 голос
/ 03 августа 2011

Я не могу сохранить свои пользовательские атрибуты клиента:

Мой бэкэнд 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

Это код моего модуля: в файле mysql4-install-0.1.0.php:

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


$installer->addAttribute('customer', 'kd_nr', array(
    'label'        => 'Kundennummer',
    'visible'      => true,
    'required'     => false,
    'position'     => 20,
   ));   
Mage::getSingleton( 'eav/config' )
->getAttribute( 'customer', 'kd_nr' )
->setData( 'used_in_forms', array( 'adminhtml_customer' ) )
->save();

$installer->endSetup();

и вот мой файл config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Mycompany_Newattcustomer>
            <version>0.1.1</version>
        </Mycompany_Newattcustomer>
    </modules>
    <global>


                <resources>
                    <newattcustomer_setup>
                        <setup>
                            <module>Mycompany_Newattcustomer</module>
                        </setup>
                        <connection>
                            <use>core_setup</use>
                        </connection>
                    </newattcustomer_setup>
                </resources>
         <fieldsets>
            <customer_account>
                        <kd_nr><create>1</create><update>1</update></kd_nr> 
            </customer_account>                
         </fieldsets>        

    </global>
</config>

Я использую Magento 1.4.2

Пожалуйста, помогите решитьэта проблема.

Большое спасибо.

[править]

Большое спасибо за помощь, кажется, что код Насараллы работает, но я обнаружил, что моя проблема пришлаиз выбора ДА / НЕТ: Вот код для поля выбора:

$installer->addAttribute('customer', 'in_search', array(
    'label'        => 'Appear in search',
    'type'         => 'int',
    'input'        => 'select',
    'source'       => 'eav/entity_attribute_source_boolean',
    'visible'      => true,
    'required'     => false,
   ));   
Mage::getSingleton( 'eav/config' )
->getAttribute( 'customer', 'in_search' )
->setData( 'used_in_forms', array( 'adminhtml_customer' ) )
->save();

Будет очень полезно, если кто-нибудь поможет мне решить действительно проблему

[/ edit]

Ответы [ 2 ]

1 голос
/ 08 августа 2011

Избавьтесь от этой части в скрипте установки

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

Чтобы вызвать eav_setup, вы должны

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

и затем вы можете обновить атрибут как:

$setup->updateAttribute ($entityTypeId,$id,$field,$value = null,$sortOrder=null)

Вы можете получить список методов, которые вы можете вызвать здесь:

Freegento-Eav-Model-entity-setup

Поэтому ваш код, я думаю, будет заменен на:

$setup->updateAttribute('customer', 'kd_nr', 'used_in_forms', 'adminhtml_customer');
0 голосов
/ 08 августа 2011

Хорошо, если вышеупомянутое не сработало вообще ... Я думаю, что давайте вернемся к вашему исходному сценарию, и я думаю, что смогу найти некоторые исправления:

    <?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();

Для получения подробной информации проверьте скрипт обновления mysql4-data-upgrade-1.4.0.0.7-1.4.0.0.8.php в ядре / Mage / Customer

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...