user975206
user975206

Reputation: 51

Magento Custom Address Attribute in Back-end

I have created a customer address attribute in Magento called 'addresstype' that is a varchar with radio options of 'Residential' and 'Business' on the front-end.

The attribute is saved during checkout and appears in the database. Customers can edit their profiles and I can actively pull the variables using $address->getAddresstype(); to check the appropriate radio button.

My only problem is that in the back-end on individual sales order pages, the variable is not coming through. I have edited /app/code/core/Mage/Customer/Block/Address/Renderer/Default.php (using $address->getAddresstype()) and can see the attribute in the array using print_r($attributes = Mage::helper('customer/address')->getAttributes());

It is marked as 'is_visible' in the database as well.

Upvotes: 2

Views: 817

Answers (1)

Peter O'Callaghan
Peter O'Callaghan

Reputation: 6186

This is because the sales order / invoice pages pull the information back from different tables (sales_flat_order_address). Assuming you have it in the right place in the first time (which it seems you do), then you just need to make Magento copy the correct information over.

<fieldsets>
    <sales_convert_quote_address>
        <your_attribute>
            <to_order>*</to_order>
        </your_attribute>
</fieldsets>

You might also have to add another field set value in to copy the value from the address to the quote address, off the top of my head I can't remember. If you search Magento's code for fieldsets in *.xml you should find examples.

Upvotes: 4

Related Questions