顧客アカウント登録ページに国の別のドロップダウンリストを追加したいのですが、試しました
<?php echo $this->getCountryHtmlSelect() ?>
しかし、これはドロップダウンを表示しません。私が試したもう1つは
<select name="partner_country" id="partner_country">
<option value=''>– Please Select –</option>
<?php foreach($_countries as $_country): ?>
<option value="<?php echo $_country->getId() ?>"><?php echo $_country->getName() ?></option>
<?php endforeach; ?>
</select>
これは国リストを表示しますが、選択した国はバックエンドの顧客情報ページに表示されません。
国のレンダリングドロップダウンを知っgetCountryHtmlSelect()
ています。選択した国を保存するために、モジュールに同様のメソッドを作成しましたか?
アップデート
セットアップスクリプトを介してこの属性を追加するときに、すでにソースモデルを作成しました。
$installer->addAttribute('customer_address','partner_country_id',array(
'type' => 'varchar',
'label' => 'Partner Country',
'input' => 'select',
'source' => 'wholesale/attribute_source_partnercountry',
'global' => 1,
'visible' => 1,
'required' => 0,
'visible_on_front' => 1,
'sort_order'=>220
));
ソースモデル
class Company_Wholesale_Model_Attribute_Source_Partnercountry extends Mage_Eav_Model_Entity_Attribute_Source_Table
{
public function getAllOptions()
{
if (!$this->_options) {
$this->_options = Mage::getResourceModel('directory/country_collection')
->loadByStore($this->getAttribute()->getStoreId())->toOptionArray();
}
return $this->_options;
}
}
config.xml
<config>
<global>
<resources>
<wholesale_setup>
<setup>
<module>Company_Wholesale</module>
<class>Company_Wholesale_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</wholesale_setup>
</resources>
</global>
</config>