我想在客户帐户注册页面中添加另一个国家/地区下拉列表。我试过了
<?php echo $this->getCountryHtmlSelect() ?>
但这不显示下拉菜单。我试过的另一个是
<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>
<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>