I have a custom customer/address attribute gmap_lat which I would like to be included in the sales/order_address_collection.

I would like to observe the customer_address_save_before event, but it isn't dispatched and I'm not sure how to hook into the Observer:


422              <customer_address_save_before>
423                  <observers>
424:                     <customer_address_before_save_viv_observer>
425                          <class>customer/observer</class>
426                          <method>beforeAddressSave</method>
427:                     </customer_address_before_save_viv_observer>
428                  </observers>
429              </customer_address_save_before>

Should I make my own observer in addition to this one, or extend the customer/observer or what? What is the best and fastest approach here?

** EDIT **:

By the way, this attribute is HIDDEN, installed in part by:

//Add attribute that will be used for Google Maps as a coordinate lat
$installer->addAttribute('customer_address', 'gmap_lat', array(
    'type'     => 'varchar',
    'input'    => 'hidden',
    'visible'  => false,
    'required' => false,
    'label'    =>   'GMap Latitude',
    'user_defined' => 0,
    'visible_on_front' => 0,
  • I installed the attribute using that and similar tutorials but I don't how it helps with observing the save event and updating a collection which is separate from customer/address? Specifically, the only hint I can find is the <fieldsets> directives, i.e. <sales_copy_order_billing_address> <jobtitle><to_order>*</to_order></jobtitle> </sales_copy_order_billing_address> which I don't understand. – blisstdev Oct 30 '14 at 17:53
  • Normally <fieldsets> <sales_copy_order_billing_address>... should copy it assuming you add the filed to quote address – Renon Stewart Oct 30 '14 at 17:58
  • See stackoverflow.com/a/8983510/1191288 – Renon Stewart Oct 30 '14 at 18:00
  • Did not work, see Edit. – blisstdev Oct 30 '14 at 18:57

R.S made me realize my question didn't make sense anyway, and he directed me to the right answer.

No one should want to update the sales/order_address_collection on save! I was getting confused between installing the attributes for the first time and how the attributes should work in the future.

If one installs the attribute as shown in http://www.magentocommerce.com/wiki/5_-_modules_and_development/how_to_add_custom_field_in_billing_and_shipping_address_in_frontend_and_backend

Then this config file will correctly copy an attribute (here called gmap_lat and gmap_lng) to and from customer_address and sales_flat_order_address, sales_flat_quote_address, at the appropriate times (during checkout).

| improve this answer | |
  • Its acceptable of stack exchange to allow self answers feel free to mark as solved. – B00MER Oct 30 '14 at 22:09
  • 2 days are over ;) – Fabian Schmengler Nov 19 '14 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.