Magento® use observer pattern to fire actions for specific events. Its becomes useful because you can modify variables before event starts or right after event ended without making rewrite of Core class. This article has almost all magento default observers list which we use for development.
How and Where it dispatched?
Magento® dispatch observer at the models and blocks where specific event happens. There is no specific rules exist when you have to dispatch observers. There are a lot of default function which dispatch observers but not all extensions have observer dispatches. If you build the extension and it have events where another developer may want to modify result then it means for you to add your own observer dispatch. It wont affect performance and it will add more flexibility to your extension or modification.What the code to dispatch observer in Magento® ?
Here is code example how Magento® dispatch customer registration success observer: The first parameter its the observer name. It should be unique for all observers for Magento® installation. The second parameter is array of variables passed to the observer. Its associative array where key will be variable name and value is object which passes to observer.How to use Observers in Magento®
Use observer is pretty easy. The first what you need to do its add declaration of it in your extension's config.xml file. For example: At the code line 5 we declare name of observer, according to the previous example its customer_register_success. The lines 7 and 11 should have unique observer handler. To avoid issues with duplicate handles you can use your extension's namespace and module name there. The line 9 states what file to use, in our example it would be extension with name Namespace_Module and file will be in the Model folder Observer.php . Its why we have there module/observer, usually instead of module you will have name of your extension's folder but observer will remain same. All observer should be in the Observer.php file of Model folder. For Example: app/code/local/Namespace/Module/Model/Observer.php . The line 10 have method of our class which will be used when for event dispatch. The second step its to make our Observer.php file with corresponding method there. At the line 5 there we can see method name which we had in config.xml file at the line 10. In the our previous example we passed customer as associative array key and customer object as value ( Line 15 at the Magento® success registration observer dispatch example ). You can see that we get customer object by calling $observer->getCustomer() at the line 6, this way we get customer object which we passed into observer. We can also use $observer->getData('customer') for it.The Magento® Observers List
Unfortunately Magento® doesn't provide list of all observers and its why we have made list of them. The list may not have all information about the observer but it has observer key and short description of it. For more details of it you can just search for it in the Magento® Core files and see at which file it dispatches to use it correctly.Observer key | Parameters | Description |
log_log_clean_before | log | before cleaning logs |
log_log_clean_after | log | after cleaning logs |
log_visitor_collection_load_before | collection | before log visitor collection loaded |
visitor_init | visitor | init visitor on the site |
api_user_authenticated | model, api_key | once api user authenticated |
page_block_html_topmenu_gethtml_before | menu, block | before menu html |
page_block_html_topmenu_gethtml_after | menu, html | after menu html generated |
adminhtml_block_eav_attribute_edit_form_init | form | init attribute form values |
eav_collection_abstract_load_before | collection | before loading eav colletion |
review_controller_product_init_before | controller_action | product review before load product |
review_controller_product_init | product | product review initilization |
review_controller_product_init_after | product,controller_action | product review after initilizaion of product |
review_review_collection_load_before | collection | review collection load before |
cms_controller_router_match_before | router, condition | cms page router match before |
cms_page_get_available_statuses | statuses | cms page statuses |
cms_wysiwyg_config_prepare | config | prepare wysiwyg congiruration |
cms_page_render | page, controller_action | render cms page action |
cms_wysiwyg_images_static_urls_allowed | result,store_id | Check of using static urls |
sendfriend_product | product | Product sent to friend action |
catalog_block_product_list_collection | collection | Before html product list collection |
catalog_product_upsell | product, collection, limit | Updating collection with desired items |
catalog_block_product_status_display | status | Display Product Stock Status |
catalog_product_type_configurable_price | product | Prepare Json Config for product |
catalog_product_view_config | response_object | Product view config json values |
catalog_controller_category_init_before | controller_action | Before Init categories |
catalog_controller_category_init_after | category, controller_action | After Init categories |
catalog_product_compare_add_product | product | Add product to compare |
catalog_category_tree_init_inactive_category_ids | tree | Retrieve inactive categories ids |
catalog_category_tree_move_before | category, prev_parent, parent | Before move category in tree |
catalog_category_tree_move_after | category, prev_node, parent | After move category in tree |
catalog_category_collection_load_before | category_collection | Before load category colection |
catalog_category_collection_load_after | category_collection | After load category caollection |
catalog_category_add_is_active_filter | category_collection | After Is Active Filter Applied |
catalog_category_change_products | category, product_ids | Save category products relation |
catalog_prepare_price_select | select, table, store_id, response_object | Prepare price select |
prepare_catalog_product_index_select | select, entity_field, website_field, store_field | Add additional external limitation |
prepare_catalog_product_price_index_table | index_table, select, entity_id, customer_group_id, website_id, website_date, update_fields | Price Index |
catalog_product_flat_prepare_columns | columns | Retrieve catalog product flat table columns array |
catalog_product_flat_prepare_indexes | indexes | Retrieve catalog product flat table indexes |
catalog_product_flat_rebuild | store_id, table | Update events observer attributes |
catalog_product_flat_update_product | store_id, table, product_ids | Update flat data for product |
category_move | category, parent, category_id, prev_parent_id, parent_id | Category Move |
catalog_product_validate_before | product | Before Validate Product Data |
catalog_product_validate_after | product | After Validate Product Data |
catalog_model_product_duplicate | current_product, new_product | Create duplicate product |
catalog_product_is_salable_before | product | Product Salable before |
catalog_product_is_salable_after | product, salable | Product salable after |
catalog_product_delete_after_done | product | Delete product |
catalog_product_status_update | product_id, store_id, status | Update status value for product |
catalog_product_prepare_save | product, request | Save product custom option data |
catalog_product_media_add_image | product, image | Add image to media gallery |
catalog_product_get_final_price | product, qty | Get product final price |
catalog_product_type_grouped_price | product | Product Final price depend of options |
catalog_controller_product_init_before | controller_action, params | Before Init product |
catalog_controller_product_init | product | Product Initilization |
catalog_controller_product_init_after | product, controller_action | After product initilization at product page |
catalog_controller_product_view | product | Prepare product render |
prepare_catalog_product_index_select | select, entity_field, website_field, store_field | Add additional external limitation for search |
catalogsearch_searchable_attributes_load_after | engine, attributes | After load searchable Attributes |
catalog_prepare_price_select | select, table, store_id, response_object | addRatedPriceFilter for search |
catalogsearch_index_process_start | store_id, product_ids | Before start catalgo search index |
admin_user_authenticate_before | username, user | Before admin authorization |
core_collection_abstract_load_before | collection | before load collection |
core_collection_abstract_load_after | collection | after load collection |
core_layout_update_updates_get_after | updates | before layout updates applied |
core_locale_set_locale | locale | set current locale |
currency_display_options_forming | currency_options, base_code | create currency for current locale |
application_clean_cache | tags | Clean cache by tags |
core_layout_block_create_after | block | After Block created |
resource_get_tablename | resourse, model_entity, table_name, table_suffix | Get Table Name |
model_load_before | boject, field, value | Before load any model |
model_load_after | object | Adter model loaded |
model_save_commit_after | object | Callback function which called after transaction commit in resource model |
core_copy_fieldset_$fieldset_$aspect | target, source, root | Copy data from object|array to object|array containing fields from fieldset matching an aspect. |
controller_action_postdispatch_adminhtml | controller_action | Google base post dispatch |
index_process_change_status | process, status | Change process status |
product_option_renderer_init | block | Wishlist option renderer init |
wishlist_add_product | wishlist, product, item | Add product to Wishlist |
wishlist_update_item | wishlist, product, item | Update Wishlist |
wishlist_share | vwishlist | Share wishlist |
wishlist_item_collection_products_after_load | product_collection | Load wishlist product collection |
wishlist_item_add_after | wishlist | After item added to wishlist |
wishlist_add_item | item | When wishlist item added |
wishlist_product_add_after | items | After items added to shilist |
bundle_product_view_config | response_object, selection | View config of bundle product |
catalog_product_prepare_index_select | website, select, bind | Prepare price index |
prepare_catalog_product_price_index_table | index_table, select, entity_id, customer_group_id, website_id, website_date, update_fields | Prepare price index table |
prepare_catalog_product_collection_prices | collection, store_id | Bundle Items Price Collection Preparation |
catalog_product_get_final_price | product, qty | get bundle product final price |
salesrule_validator_process | rule, item, address, quote, qty, result | Sales Rule validator process |
sales_quote_address_discount_item | item | Discount Item |
salesrule_rule_condition_combine | additional | Additional conditions for sales rule conditions |
salesrule_rule_get_coupon_types | transport | Get coupon coe types |
review_controller_product_init_before | controller_action | Xmlconnect review controller before init of product |
review_controller_product_init | product | Xmlconnect review controller init of product |
review_controller_product_init_after | product, controller_action | Xmlconnect review controller init after |
checkout_controller_onepage_save_shipping_method | requests, quote | save shipping method action |
wishlist_add_product | wishlist, product, item | Xmlconnect wishliast add product action |
checkout_cart_add_product_complete | product, request, response | checkout add to cart complete action |
enterprise_giftcardaccount_add | status, code | Xmlconnect Fail of giftaccount add in the cart |
checkout_cart_update_item_complete | item, request, response | Complete of checkout cart item update |
before_save_message_queue | queueMessage | XmlConnect Queue message before save |
checkout_controller_multishipping_shipping_post | request, quote | Multishiping shipping post |
checkout_multishipping_controller_success_action | order_ids | Success action of checkout |
checkout_cart_product_add_after | quote_item, product | After product added to the cart |
checkout_cart_update_items_before | cart, info | Before update cart items |
checkout_cart_update_items_after | cart, info | After updae cart items |
checkout_cart_save_before | cart | Before cart saved |
checkout_cart_save_after | cart | After cart saved |
checkout_cart_product_update_after | quote_item, product | After cart product update |
custom_quote_process | checkout_session | getQuote action for checkot |
checkout_quote_init | quote | Init of quote |
load_customer_quote_before | checkout_session | Load data for customer quote and merge with current quote |
checkout_quote_destroy | quote | Quote destroy action |
checkout_type_multishipping_set_shipping_items | quote | Assign quote items to addresses and specify items qty |
checkout_type_multishipping_create_orders_single | order, address | Create orders per each quote address |
checkout_submit_all_after | orders, quote, recurring_profiles | Submit Order |
checkout_multishipping_refund_all | orders, quote | Refund Multishipping order |
checkout_type_onepage_save_order_after | order, quote | After order saved |
checkout_allow_guest | quote, store, result | Is checkot allowed for guest action |
rss_wishlist_xml_callback | product | Xml wishlist callback |
rss_catalog_new_xml_callback | product | RSS new xml |
rss_catalog_notify_stock_collection_select | collection | Notify Stock collection RSS select |
rss_catalog_tagged_item_xml_callback | product | Rss tagged item |
rss_catalog_special_xml_callback | product | Special Rss xml callback |
rss_catalog_review_collection_select | collection | RSS reviews collection |
rss_catalog_category_xml_callback | product | RSS categories |
rss_order_new_collection_select | collection | RSS orders collection |
poll_vote_add | poll, vote | RSS of vote add action |
adminhtml_block_promo_widget_chooser_prepare_collection | collection | Prepare Promo Widget Collection |
adminhtml_promo_catalog_edit_tab_main_prepare_form | form | Catalog promo rules prepare tab |
adminhtml_block_salesrule_actions_prepareform | form | Sales rules prepare form |
adminhtml_promo_quote_edit_tab_coupons_form_prepare_form | form | Prepare coupons form |
adminhtml_promo_quote_edit_tab_main_prepare_form | form | Preprare form of coupon rule main tab |
api_user_html_before | block | Adminhtml Permissions user block |
adminhtml_widget_grid_filter_collection | collection, filter_values | Adminhtml Wigdet Grid Filter Collection |
adminhtml_cms_page_edit_tab_main_prepare_form | form | Adminhtml Cms Page Edit Main Tab Form |
adminhtml_cms_page_edit_tab_design_prepare_form | form | Adminhtml Cms Page Edit Design Tab Form |
adminhtml_cms_page_edit_tab_meta_prepare_form | form | Adminhtml Cms Page Edit Meta Tab Form |
adminhtml_cms_page_edit_tab_content_prepare_form | form | Adminhtml Cms Page Edit Content Tab Form |
adminhtml_widget_container_html_before | block | Adminhtml Widget Container Before Html |
adminhtml_catalog_category_tree_is_moveable | options | Adminhtml Is category moveable |
adminhtml_catalog_category_tree_can_add_root_category | category, options, store | Adminhml Check availability of adding root category |
adminhtml_catalog_category_tree_can_add_sub_category | category, options, store | Adminhtml Check availability of adding sub category |
adminhtml_catalog_category_tabs | tabs | Adminhtml Catalog Category Tabs |
adminhtml_catalog_category_edit_prepare_form | form | Adminhtml Category Edit Form |
adminhtml_catalog_product_attribute_set_toolbar_main_html_before | block | Adminhtml Catalog Product Attribute set toolbar |
adminhtml_catalog_product_attribute_set_main_html_before | block | Adminhtml Attribute Set Main Block |
adminhtml_catalog_product_edit_prepare_form | form | Adminhtml product edit form |
adminhtml_catalog_product_edit_element_types | response | Adminhtml product edit element types |
adminhtml_product_attribute_types | response | Adminhtml product edit set attribute types |
adminhtml_catalog_product_attribute_edit_prepare_form | form, attribute | Adminhtml product attribute edit form |
adminhtml_catalog_product_grid_prepare_massaction | block | Adminhtml product mass actions |
adminhtml_catalog_product_form_prepare_excluded_field_list | object | Adminhtml Product Edit excluded fields |
adminhtml_catalog_product_edit_tab_attributes_create_html_before | block | Adminhtml create Attributes |
catalog_product_edit_form_render_recurring | result, product_element, product | Adminhtml Product Edit Recurrent Tab |
catalog_product_gallery_prepare_layout | block | Adminhtml Product Edit Gallery |
adminhtml_block_html_before | block | Adminhtml before each admin block |
permissions_user_html_before | block | Adminhtml before permissions block |
adminhtml_customer_orders_add_action_renderer | renderer, row | Adminhtml Customer Order Add Renderer |
adminhtml_store_edit_form_prepare_form | form | Adminhtml Store Edit Form |
adminhtml_system_config_advanced_disableoutput_render_before | modules | Adminhtml Disable Modules |
adminhtml_block_system_config_init_tab_sections_before | section | Adminhtml System Config Sections Before |
adminhtml_controller_catalogrule_prepare_save | request | Adminhtml Catalogrule prepare save |
adminhtml_controller_salesrule_prepare_save | request | Adminhtml Sales Rule Prepare Save |
adminhtml_cache_refresh_type | type | Adminhtml Flush Cache by Type |
cms_page_prepare_save | page, request | Adminhtml Save Cms Page |
adminhtml_cmspage_on_delete | title, status | Adminhtml Delete Cms Page |
catalog_product_new_action | product | Adminhtml New Product |
catalog_product_edit_action | product | Adminhtml Edit Product |
catalog_product_prepare_save | product, request | Adminhtml Prepare Save Product |
product_duplicate_attributes | product, storeTo, storeFrom | Adminhtml Product Copy Attributes Between Stores |
catalog_controller_product_delete | product | Adminhtml Delete Product |
category_prepare_ajax_response | response, controller | Adminhtml Category Prepare Ajax Response |
catalog_category_prepare_save | category, request | Adminhtml Category Prepare Save |
catalog_controller_category_delete | category | Adminhtml Delete Category |
catalog_product_stock_item_mass_change | products | Adminhtml Stock Item Mass Change |
catalog_product_to_website_change | products | Adminhtml Product o Website Change |
catalog_product_gallery_upload_image_after | result, action | Adminhtml After Gallery Upload |
admin_permissions_role_prepare_save | object, request | Adminhtml Permissions Role Save |
sales_order_status_unassign_before | status, state | Adminhtm Before Order Status Unassign |
create_order_session_quote_initialized | session_quote | Adminhtml Create Order Session Quote Init |
adminhtml_sales_order_create_process_data_before | order_create_model, request_model, session | Adminhtml Create Order Process Action Data |
adminhtml_sales_order_create_process_data | order_create_model, request | Adminhtml Create Order Process Action Data Before |
adminhtml_sales_order_creditmemo_register_before | creditmemo, request | Adminhtml before Register Credit Memo |
on_view_report | report | Adminhtml View Report |
adminhtml_customer_prepare_save | customer, request | Adminhtml Customer Save |
adminhtml_customer_save_after | customer, request | Adminhtml Customer Save After |
admin_system_config_section_save_after | website, store, section | Adminhtml System Config Save After |
admin_system_config_changed_section_{$section} | website, store, section | Adminhtml System Config Section Changed |
store_group_save | group | Adminhtml System Store Group Save |
store_edit | store | Adminhtml System Store Group Edit |
store_delete | store | Adminhtml Store Delete |
{{event_prefix}}_finish_before | adapter | Adminhtml Import Adapter. Each adapter has event prefix |
adminhtml_init_system_config | config | Adminhtml Init System Config |
model_config_data_save_before | object | Adminhtml Config Save Before |
init_from_order_session_quote_initialized | session_quote | Init Quote From Order |
sales_convert_order_to_quote | order, quote | Convert Order to Quote |
sales_convert_order_item_to_quote_item | order_item, quote_item | Convert Order Item to Quote Item |
checkout_submit_all_after | order, quote | Checkout Submit All After |
catalogindex_prepare_price_select | select, table, store_id, response_object | Preprare Price Select |
catalogindex_plain_reindex_after | products | Plain Reindex After |
catalogindex_get_minimal_price | indexer, product_ids, store | Index Product Minimal Price |
{{event_object}}_set_sales_order | collection, {{event_object}}, order | Set sales order model |
sales_resource_init_virtual_grid_columns | resourse | Init Virtual Grid Columns |
sales_resource_update_grid_records | proxy | Update Records in grid table |
sales_sale_collection_query_before | collection | Resource Sale Collection |
sales_order_place_before | order | Before order Placed |
sales_order_place_after | order | After Order Placed |
order_cancel_after | order | After Order Cancelled |
clear_expired_quotes_before | sales_observer | Before Clean Expired Quotes |
sales_quote_remove_item | quote_item | Quote remove Item |
sales_quote_add_item | quote_item | Quote Add Item |
sales_quote_product_add_after | items | Quote Add Product After |
sales_quote_collect_totals_before | quote | Quote Collect Totals Before |
sales_quote_collect_totals_after | quote | Quote Collect Totals After |
sales_quote_merge_before | quote, source | Before Quote Mege |
sales_quote_merge_after | quote, source | After Quote Mege |
pdf_item_draw_after | transport_object, entity_item | PDF Draw Item Process |
sales_order_invoice_pay | invoice | Invoice Pay Event |
sales_order_invoice_cancel | invoice | Invoice Cancel |
sales_order_invoice_register | invoice, order | Invoice Register |
sales_order_creditmemo_refund | creditmemo | Creditmemo Refund |
sales_order_creditmemo_cancel | creditmemo | Cancel Creditmemo |
sales_order_payment_place_start | payment | Start Place Payment |
sales_order_payment_place_end | payment | Payment Placed |
sales_order_payment_capture | payment, invoice | Invoice Payment Capture |
sales_order_payment_pay | payment, invoice | Invoice Payment Pay |
sales_order_payment_cancel_invoice | payment, invoice | Invoice Payment Cancel |
sales_order_payment_void | payment, invoice | Invoice Payment Void |
sales_order_payment_refund | payment, creditmemo | Payment Refund |
sales_html_txn_id | transaction, payement | Transaction |
sales_order_payment_cancel_creditmemo | payment, creditmemo | Payment Cancel Creditmemo |
sales_order_payment_cancel | payment | Cancel Payment |
sales_order_item_cancel | items | Order Item Cancel |
sales_order_payment_transaction_load_by_txn_id_before | txn_id | Before Load Transaction |
sales_quote_address_collect_totals_before | quote_address | Before Collect Totals |
sales_quote_address_collect_totals_after | quote_address | After Collect Totals |
sales_quote_config_get_product_attributes | attribute | Quote get product attributes |
sales_quote_address_discount_item | item | Discount Quote Item |
sales_quote_payment_import_data_before | payment, input | Before Import Payment |
sales_quote_item_qty_set_after | item | Set Item Quote Item Quantity |
sales_quote_item_set_product | product, quote_item | Set Quote Item Product |
sales_convert_quote_to_order | order, quote | Convert Quote to Order |
sales_convert_quote_address_to_order | address, order_address | Convert Quote Address To Order Address |
sales_convert_quote_item_to_order_item | order_item, item | Convert Quote Item to Order Item |
sales_prepare_amount_expression | collection, expression_object | Get Sales Amount Expression |
tax_rate_data_fetch | request | Get Tax Rate |
catalog_product_import_finish_before | adapter | Before Finish Product Import |
tag_tag_product_collection_load_after | collection | Tag Product Collection Load After |
customer_register_success | account_controller, customer | Customer Success Registration |
customer_address_format | type, address | Format Customer's Address |
customer_address_validation_after | address | Customer Address Validation After |
customer_session_init | customer_session | Init Customer Session |
customer_login | customer | Customer Login |
customer_logout | customer | Customer Logout |
customer_customer_authenticated | model, password | Customer Authenticated |
customer_registration_is_allowed | result | Is registration ALlowed |
rule_environment_collect | env | Collect application environment for rules filtering |
admin_system_config_changed_section_currency_before_reinit | website, store | Before Changed Currency at the Admin Config |
admin_system_config_changed_section_currency | website, store | Changed Currency at the Admin Config |
paypal_prepare_line_items | paypal_cart | Prepare Paypal Cart Items |
paypal_payment_transaction_load_by_txn_id_before | paypal_payment_transaction, txn_id | Load Paypal Transaction Before |
paypal_payment_transaction_load_by_txn_id_after | paypal_payment_transaction | Load Paypal Transaction After |
gift_options_prepare_items | items | Prepare Giftcard Items |
payment_form_block_to_html_before | block | Payment Block To Html |
payment_info_block_prepare_specific_information | transport, payment, block | Prepare Payment Information |
payment_method_is_active | result, method_instance, quote | Is Active Payment Method |