Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento Save Selected Country
    text
    copied!<p>I want to add another dropdown list of countries in customer account register page.I tried </p> <pre><code>&lt;?php echo $this-&gt;getCountryHtmlSelect() ?&gt; </code></pre> <p>But this doesn't display the dropdown.Another one I tried is</p> <pre><code>&lt;select name="partner_country" id="partner_country"&gt; &lt;option value=''&gt;– Please Select –&lt;/option&gt; &lt;?php foreach($_countries as $_country): ?&gt; &lt;option value="&lt;?php echo $_country-&gt;getId() ?&gt;"&gt;&lt;?php echo $_country-&gt;getName() ?&gt;&lt;/option&gt; &lt;?php endforeach; ?&gt; &lt;/select&gt; </code></pre> <p>This one displays country list, but the selected country doesn't show up in backend customer information page.</p> <p>I know <code>getCountryHtmlSelect()</code> renders dropdown of countries.Do I have create similar method in my module to save the selected country?</p> <p><strong>Update</strong></p> <p>I already created a source model while adding this attribute via setup script,</p> <pre><code>$installer-&gt;addAttribute('customer_address','partner_country_id',array( 'type' =&gt; 'varchar', 'label' =&gt; 'Partner Country', 'input' =&gt; 'select', 'source' =&gt; 'wholesale/attribute_source_partnercountry', 'global' =&gt; 1, 'visible' =&gt; 1, 'required' =&gt; 0, 'visible_on_front' =&gt; 1, 'sort_order'=&gt;220 )); </code></pre> <p>Source model</p> <pre><code>class Company_Wholesale_Model_Attribute_Source_Partnercountry extends Mage_Eav_Model_Entity_Attribute_Source_Table { public function getAllOptions() { if (!$this-&gt;_options) { $this-&gt;_options = Mage::getResourceModel('directory/country_collection') -&gt;loadByStore($this-&gt;getAttribute()-&gt;getStoreId())-&gt;toOptionArray(); } return $this-&gt;_options; } } </code></pre> <p>config.xml</p> <pre><code>&lt;config&gt; &lt;global&gt; &lt;resources&gt; &lt;wholesale_setup&gt; &lt;setup&gt; &lt;module&gt;Company_Wholesale&lt;/module&gt; &lt;class&gt;Company_Wholesale_Model_Entity_Setup&lt;/class&gt; &lt;/setup&gt; &lt;connection&gt; &lt;use&gt;core_setup&lt;/use&gt; &lt;/connection&gt; &lt;/wholesale_setup&gt; &lt;/resources&gt; &lt;/global&gt; &lt;/config&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload