2012-07-04 3 views
-1

magento 1.5 0에서 사용자 정의 등록 필드를 추가하려고했습니다. Adding custom registration fields in magento 1.5 및 그 밖에도 여러 가지 방법으로 시도했습니다. 하지만 필드에 등록하는 동안 데이터를 추가해도 customer_entity_varchar 테이블에는 저장되지 않고 테이블 eav_attribute에 추가 된 속성도 없습니다. app/local/Mycustommodule/Customer/sql/customerattribute_setup/mysql4-install-0.1.0.php이에서magento에서 사용자 정의 등록 필드를 추가하는 방법 1.5

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/Model/Entity/Setup.php에서이

<?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/etc/config.xml에서이

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

:이이 app/local/etc/modules/Mycustommodule_Customer.xml에서

: 이것은 내 코드입니다

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

691,363,210은 내가이 app/design/frontend/default/mycustommodule/template/customer/form/register.phtml에 정리하고 app/design/frontend/default/mycustommodule/template/customer/form/edit.phtml

내가 잘못되거나 누락 무슨 짓을 추가 ???

+0

다를 파일? 게시 한 코드의 어느 부분에도 정의되어 있지 않습니다. –

+0

아, 아마 그게 문제예요. 나는 노력한다. thx – Teddy115

+0

이것을 추가합니다. $ eavconfig = new Mage_Eav_Model_Entity_Setup ('core_setup'); 그러나 그것은 아무것도 바뀌지 않습니다. 난 여전히 customer_entity_varchar 및 "전화"에 관한 테이블 eav_attribute에 어떤 가치도 없어 – Teddy115

답변

0

아래 링크를 클릭하면 도움이되기를 바랍니다.

How to create new fields for customer

만보기 (로 .phtml)는 경로가 1.5 그리고 그`$ eavConfig` 개체에서 오는가 1.6

+0

당신의 빠른 대답을 주셔서 감사합니다하지만 내가 뭘보고 싶어? 또한이 솔루션을 register.phtml에 추가하여 다음 해결책을 시도했습니다. $ setup = new Mage_Eav_Model_Entity_Setup ('core_setup') (http://www.magentocommerce.com/wiki/5_-_modules_and_development/customers_and_accounts/registration_fields) ; $ AttrCode = '직업'; $ settings = array ( '위치'=> 1, 'is_required'=> 0 ); $ setup-> addAttribute ('1', $ AttrCode, $ settings); – Teddy115

관련 문제