1

onepage チェックアウト プロセス中に、配送先住所用の新しいフィールド「custom_house_no」を追加したいと考えています。

カスタム拡張 mysql ファイル「mysql4-install-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/Model/Entity/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」フィールドを除くすべてのデータがデータベースに保存されています。

私のコードの何が問題なのかわかりません。

4

1 に答える 1

0

ほとんどの場合、フィールドセットで遊ぶ必要があります。コア Mage/Checkout モジュールの config.xml で定義されているものを見て、モジュール構成でそれらを拡張します。

于 2011-08-10T05:44:41.547 に答える