2013-12-12 71 views
0

我想在註冊表格中添加多個字段。在magento註冊表格中添加多個字段

安裝文件是: -

<?php 

    $installer = $this; 
    $installer->startSetup(); 
    $setup = Mage::getModel('customer/entity_setup', 'core_setup'); 
    $setup->addAttribute('customer', 'accounttype', array(
'type' => 'int', 
'input' => 'select', 
'label' => 'Accounttype', 
'global' => 1, 
'visible' => 1, 
'required' => 0, 
'user_defined' => 1, 
'default' => '0', 
'visible_on_front' => 1, 
    'source' => 'profile/entity_accounttype', 
)); 

    $setup->addAttribute('customer', 'tva', array(
'type' => 'int', 
'input' => 'select', 
'label' => 'Tva', 
'global' => 1, 
'visible' => 1, 
'required' => 0, 
'user_defined' => 1, 
'default' => '0', 
'visible_on_front' => 2, 
'source' => 'profile/entity_tva', 
)); 
    $setup->addAttribute('customer', 'companycountry', array(
'type' => 'varchar', 
'input' => 'text', 
'label' => 'Companycountry', 
'global' => 1, 
'visible' => 1, 
'required' => 0, 
'user_defined' => 1, 
'default' => '0', 
'visible_on_front' => 4, 
'source' => 'profile/entity_companycountry', 
)); 
$setup->addAttribute('customer', 'companycomment', array(
'type' => 'varchar', 
'input' => 'text', 
'label' => 'Companycomment', 
'global' => 1, 
'visible' => 1, 
'required' => 0, 
'user_defined' => 1, 
'default' => '0', 
'visible_on_front' => 3, 
'source' => 'profile/entity_companycomment', 
)); 
    if (version_compare(Mage::getVersion(), '1.6.0', '<=')) 
    { 
$customer = Mage::getModel('customer/customer'); 
$attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId(); 
$setup->addAttributeToSet('customer', $attrSetId, 'General',   'accounttype','tva','companycountry','companycomment'); 
    } 

    if (version_compare(Mage::getVersion(), '1.4.2', '>=')) 
{ 
Mage::getSingleton('eav/config') 
->getAttribute('customer', 'accounttype', 'tva','companycountry','companycomment') 
->setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit','checkout_register')) 
->save(); 

    } 

$tablequote = $this->getTable('sales/quote'); 
    $installer->run(" 
    ALTER TABLE $tablequote ADD `customer_accounttype` INT NOT NULL, 
         ADD `customer_tva` INT NOT NULL, 
       ADD `customer_companycountry` varchar(100) NOT NULL, 
       ADD `customer_companycomment` varchar(1000) NOT NULL 
    "); 

    $installer->endSetup(); 

我製成4源模型爲每個字段。我們只有一個字段&數據也沒有保存在數據庫中。請幫我,我錯了。

+0

這些是與客戶相關的字段/屬性。在管理員中創建這些不是更好嗎?如果您配置它們,它們將顯示在註冊表單中。 – russjman

回答

1

你可以通過這個鏈接Magento Module Creater

Need Add Customer Attribute :是創建模塊,它會給現場爲您的客戶屬性。並創建字段儘可能多。創建字段後,只需點擊Create Magento Module (download)它會給你一個準備好你的自定義客戶屬性模塊。 Note:- Selecte **Forms to Use In**其中您的字段將填充爲用戶輸入

希望這會幫助你。

相關問題