我想添加在客戶賬戶的國家的另一個下拉列表登記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