我想添加在客户账户的国家的另一个下拉列表登记page.I试图Magento的保存选定国家
<?php echo $this->getCountryHtmlSelect() ?>
但这并不显示dropdown.Another一个我想是
<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>
感谢@bImage的输入 – blakcaps 2012-07-23 09:21:57