-1

私はmagento1.50にカスタム登録フィールドを追加しようとしました。magento1.5にカスタム登録フィールドを追加するなど、私が見つけた他の多くの方法で追加しようとしました。しかし、フィールドの登録中にデータを追加すると、そのデータはテーブルcustomer_entity_varcharに保存されず、どちらの属性もテーブルeav_attributeに追加されません。これは私のコードです:

私はこれapp/local/etc/modules/Mycustommodule_Customer.xmlを持っています:

<config>
    <modules>
        <Mycustommodule_Customer>
            <active>true</active>
            <codePool>local</codePool>
        </Mycustommodule_Customer>
    </modules>
</config>

これapp/local/Mycustommodule/Customer/etc/config.xmlで:

<?xml version="1.0"?>
<config>
    <modules>
        <Mycustommodule_Customer>
            <version>0.1.0</version>
        </Mycustommodule_Customer>
    </modules>
    <global> 
        <models>
            <Mycustommodule_Customer>
                <class>Mycustommodule_Customer_Model</class>
            </Mycustommodule_Customer>
        </models>
        <resources>
            <customerattribute_setup>
        <setup>
            <modules>Mycustommodule_Customer</modules>
            <class>Mycustommodule_Customer_Model_Entity_Setup</class>
        </setup>    
                <connection>
                    <use>core_setup</use>
                </connection>
            </customerattribute_setup>
            <customerattribute_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </customerattribute_write>
            <customerattribute_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </customerattribute_read>     
        </resources>
        <blocks>     
            <mycustommodule_customerattribute>
                <class>Mycustommodule_Customer_Block</class>
            </mycustommodule_customerattribute>    
        </blocks>       
        <helpers>
        <mycustommodule_customerattribute>
        <class>Mycustommodule_Customer_Helper</class>      
        </mycustommodule_customerattribute>
        </helpers>
        <fieldsets>
            <customer_account> 
                <phone><create>1</create><update>1</update></phone>
            </customer_account>
        </fieldsets>  
    </global>    
</config>

これapp/local/Mycustommodule/Customer/Model/Entity/Setup.phpで:

class Mycustommodule_Customer_Model_Entity_Setup  extends Mage_Customer_Model_Entity_Setup
{


    public function getDefaultEntities()
    {

        $defaultEntities = parent::getDefaultEntities();

        $defaultEntities['customer']['attributes']['phone'] = array(
                        'label'        => 'Phone Number',
                        'visible'      => 1,
                        'required'     => 1,
                        'position'     => 1,
                    );                           
        return $defaultEntities;
    }

}

これapp/local/Mycustommodule/Customer/sql/customerattribute_setup/mysql4-install-0.1.0.phpで:

$installer->startSetup();

$installer->addAttribute('customer','phone', array(
'label' => 'Phone Number',
'visible'   => 1,
'required'  => 1,
'position'  => 1,
));


$installer->endSetup();
// Get Customer Type ID
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
$eid = $read->fetchRow(
    "select entity_type_id from {$this->getTable('eav_entity_type')} where entity_type_code = 'customer'"
);
$customer_type_id = $eid['entity_type_id'];

// Save Attribute to the customer_form_attribute
$attribute = $eavConfig->getAttribute($customer_type_id, 'phone');

// Here is where you determine in wich areas of magento the attributes are used
$attribute->setData('used_in_forms', array('customer_account_edit', 'customer_account_create', 'adminhtml_customer'));
$attribute->save();

にファイルを追加しapp/design/frontend/default/mycustommodule/template/customer/form/register.phtmlapp/design/frontend/default/mycustommodule/template/customer/form/edit.phtml

私が間違ったことや逃したこと???

4

1 に答える 1

0

以下のリンクがお役に立てば幸いです。

顧客用の新しいフィールドを作成する方法

ビュー (.phtml) ファイルのパスのみが 1.5 と 1.6+ で異なります

于 2012-07-04T10:33:19.913 に答える