Kundenadresse beachten speichern, Sammlung aktualisieren
-
12-12-2019 - |
Frage
Ich habe einen Brauch customer/address
Attribut gmap_lat
in die ich gerne aufgenommen werden möchte sales/order_address_collection
.
Ich möchte die beobachten customer_address_save_before
ereignis, aber es wird nicht ausgelöst und ich bin mir nicht sicher, wie ich mich in den Beobachter einhaken soll:
magento\app\code\core\Mage\Customer\etc\config.xml:
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>
Soll ich zusätzlich zu diesem einen eigenen Beobachter machen oder den erweitern customer/observer
oder was?Was ist hier der beste und schnellste Ansatz?
** BEARBEITEN **:
Übrigens ist dieses Attribut VERSTECKT, teilweise installiert von:
//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,
));
Lösung
RS machte mir klar, dass meine Frage sowieso keinen Sinn ergab, und er wies mich auf die richtige Antwort hin.
Niemand sollte die sales / order_address_collection beim Speichern aktualisieren wollen!Ich war verwirrt zwischen der erstmaligen Installation der Attribute und der zukünftigen Funktionsweise der Attribute.
Wenn man das Attribut wie in installiert http://www.magentocommerce.com/wiki/5_-_modules_and_development/how_to_add_custom_field_in_billing_and_shipping_address_in_frontend_and_backend
Dann kopiert diese Konfigurationsdatei ein Attribut (hier gmap_lat und gmap_lng genannt) zu und von customer_address und sales_flat_order_address , sales_flat_quote_address zu den entsprechenden Zeiten (während des Bezahlvorgangs) korrekt.
<global>
<resources>
<sw_firsttime_setup>
<setup>
<module>StrollingWild_FirstTimeCustomer</module>
<class>Mage_Customer_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</sw_firsttime_setup>
<sw_firsttime_write>
<connection>
<use>core_write</use>
</connection>
</sw_firsttime_write>
<sw_firsttime_read>
<connection>
<use>core_read</use>
</connection>
</sw_firsttime_read>
</resources>
<helpers>
<firsttimecustomer>
<class>StrollingWild_FirstTimeCustomer_Helper</class>
</firsttimecustomer>
</helpers>
<admin>
<fieldsets>
<customer_dataflow>
<gmap_lng><billing>1</billing><shipping>1</shipping></gmap_lng>
<gmap_lat><billing>1</billing><shipping>1</shipping></gmap_lat>
</customer_dataflow>
</fieldsets>
</admin>
<fieldsets>
<customer_address>
<gmap_lat><to_quote_address>*</to_quote_address></gmap_lat>
<gmap_lng><to_quote_address>*</to_quote_address></gmap_lng>
</customer_address>
<sales_copy_order_billing_address>
<gmap_lat><to_order>*</to_order></gmap_lat>
<gmap_lng><to_order>*</to_order></gmap_lng>
</sales_copy_order_billing_address>
<sales_copy_order_shipping_address>
<gmap_lat><to_order>*</to_order></gmap_lat>
<gmap_lng><to_order>*</to_order></gmap_lng>
</sales_copy_order_shipping_address>
<sales_convert_quote_address>
<gmap_lat>
<to_order_address>*</to_order_address>
<to_customer_address>*</to_customer_address>
</gmap_lat>
<gmap_lng>
<to_order_address>*</to_order_address>
<to_customer_address>*</to_customer_address>
</gmap_lng>
</sales_convert_quote_address>
<sales_convert_order_address>
<gmap_lat><to_quote_address>*</to_quote_address></gmap_lat>
<gmap_lng><to_quote_address>*</to_quote_address></gmap_lng>
</sales_convert_order_address>
</fieldsets>
</global>