2011-08-09 2 views
1

한 페이지 계산 과정 중에 배송지 주소로 "custom_house_no"라는 새 필드를 추가하고 싶습니다.Magento - 한 페이지 계산 과정 중에 주소를 배송 할 새 필드 추가

내 사용자 정의 확장 MySQL의 파일에 아래의 코드를 추가 한 "mysql4 --0.1.0.php 설치"나는 또한 폴더에 클래스를 만든


    // Customer Address 
    $entityTypeId  = $installer->getEntityTypeId('customer_address'); 
    $attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId); 
    $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);

$installer->addAttribute('customer_address', 'custom_house_no', array(
    'label'    => 'Custom House No', 
    'input'    => 'text', // Input field type textbox 
    'type'    => 'varchar', // Store varchar data type 
    'frontend'   => '', //frontend model 
    'backend'   => '', //backend model 
    'visible'   => 1, //true 
    'required'   => 0, //false 
    'user_defined'  => 1, 
    'default'   => '', //default value 
    'searchable'  => 0, 
    'filterable'  => 0, 
    'comparable'  => 0, 
    'visible_on_front' => 0, 
    'unique'   => 0, 
    'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL 
    // 'class'    => '', 
    // 'source'   => 'catalog/category_attribute_source_page', 
)); 

$installer->addAttributeToGroup(
    $entityTypeId, 
    $attributeSetId, 
    $attributeGroupId, 
    'custom_house_no', 
    '150'  //last Magento's attribute position in General tab is 140 
); 

$attribute = Mage::getSingleton('eav/config')->getAttribute('customer_address', 'custom_house_no'); 
$attribute->setData('used_in_forms', array('customer_register_address', 'customer_address_edit', 'adminhtml_customer_address')); // Setting the relation between the attribute and forms in which this attribute will be used 
$attribute->save();` 

MY/CustomExtension/모델/엔티티/Setup.php


    class MY_CustomExtension_Model_Entity_Setup extends Mage_Eav_Model_Entity_Setup { 
    } 

또한 확장 구성 파일에 클래스 이름을 추가했습니다.


    Link to config code : Config File Content 

배송 템플릿 파일에는 "custom_house_no"라는 텍스트 상자가 추가되었습니다.

속성이 성공적으로 추가되었으며 양식과의 관계가 있지만 모든 데이터는 "custom_house_no"필드를 제외하고 데이터베이스에 저장됩니다.

내 코드에 어떤 문제가 있는지 알 수 없습니다.

답변

0

대부분의 경우 필드 세트를 사용해야합니다. 핵심 Mage/Checkout 모듈의 config.xml에 정의 된 것을 살펴보고 모듈 구성에서 확장하십시오.

관련 문제