I have added a custom attribute to customer address(to select address type commercial or residential) using Hwg Attribute manager extension(Manage Category, Customer and Customer Address Attributes). It is working in the back end. But the problem is not working for the front end. So i have added this code to
app/design/frontend/base/default/template/customer/address/edit.phtml
<li class="fields">
<label for="billing:addresstype" class="required"><em>*</em><?php echo $this->__('Address Type') ?></label>
<div class="input-box">
<select name="billingaddresstype" id="billingaddresstype">
<?php $collection = Mage::getResourceModel('eav/entity_attribute_option_collection');
$collection->setAttributeFilter(174);
$collection->setStoreFilter();
$collection->load();
$options = $collection->toOptionArray();
foreach ($options as $option) {
echo "<option value='".$option['value']."'>".$option['label']."</option>";
}
?>
</select><?php //var_dump($options); ?>
</div>
</li>
Now the combo box is appear in the front end. But it doesn’t save data. Then i check the submitting form values in the AddressController
$addressForm = Mage::getModel('customer/form');
$addressForm->setFormCode('customer_address_edit')
->setEntity($address);
$addressData = $addressForm->extractData($this->getRequest());
var_dump($addressData);
break;
It doesn’t contain my custom attribute values.
array(11) { ["firstname"]=> string(8) "thushara"
["lastname"]=> string(11) "Mannaperuma"
["company"]=> string(3) "flt"
["street"]=> array(2)
{ [0]=> string(17) "1234 Heartwood Dr" [1]=> string(0) "" }
["city"]=> string(10) "Beltsville"
["country_id"]=> string(2) "US"
["region"]=> string(0) ""
["region_id"]=> string(2) "31"
["postcode"]=> string(5) "20705"
["telephone"]=> string(12) "548-789-6548"
["fax"]=> string(0) "" }
I’ stuck at this point.
I worked it out.
Make sure you have the latest version of the Hwg Attribute manager extension.
you can use this link direct-download-magento-extension to get the extension as a zip file.
This is the code i used to get my custom attribute to the frontend. and it is saving data correctly.
adtype is my attribute code. field name and id must be the attribute code.