Magento事件Events介绍

本文将讨论 Magento 2中的事件列表。如您所知,Magento 2是使用事件驱动的架构,这将帮助扩展Magento功能。我们可以理解这个事件是在特定情况发生时一种标志(flag)。。我们将使用一个示例模块Magentochina_HelloWorld来学习这一课。


##调度事件 Dispatch event
在Magento 2事件列表中,我们可以使用类 Magento\Framework\Event\Manager来分派事件。例如,我们在Magentochina_HelloWorld中创建一个控制器动作,以在屏幕上显示“Hello World”这个词:
文件:

app/code/Magentochina/HelloWorld/Controller/Hello/World.php

<?php
namespace Magentochina\HelloWorld\Controller\Hello;

class World extends \Magento\Framework\App\Action\Action
{
  public function execute()
{
 echo 'Hello World';
 exit;
}
}

现在我们要发送一个 magento 2事件列表,允许其他模块可以更改显示的单词。我们将会像这样改变控制器:
文件:

app/code/Magentochina/HelloWorld/Controller/Hello/World.php

<?php
namespace Magentochina\HelloWorld\Controller\Hello;

class World extends \Magento\Framework\App\Action\Action
{
public function execute()
{
 $textDisplay = new \Magento\Framework\DataObject(array('text' => 'Magentochina'));
 $this->_eventManager->dispatch('magentochina_helloworld_display_text', ['text' => $textDisplay]);
 echo $textDisplay->getText();
 exit;
}
}

dispatch方法将接收两个参数:一个惟一的事件名和一个数组数据。在这个示例中,我们将数据对象添加到事件中,并调用它以显示文本。
##捕获并处理事件 Catch and handle event
###事件区域 Event area
Magento使用区域定义来管理商店。我们将有一个前端区域和管理区域。在配置文件中,可以放置3个位置:

  • etc /文件夹下配置可以在后台管理端和前端使用。
  • etc/frontend文件夹将被用于前端。
  • etc/adminhtml文件夹下将被用于后台。

事件配置文件也是如此。您可以为每个区域创建事件配置文件:

  • 后台管理区域: app/code/Magentochina/HelloWorld/etc/adminhtml/events.xml
  • 前端区: app/code/Magentochina/HelloWorld/etc/frontend/events.xml
  • 全局: app/code/Magentochina/HelloWorld/etc/events.xml

###创建events.xml
在本例中,我们只捕捉事件,以显示正面的单词Magentochina,因此我们应该创建一个events.xml文件在etc / frontend文件夹。
文件:

app/code/Magentochina/HelloWorld/etc/frontend/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
 <event name="magentochina_helloworld_display_text">
   <observer name="hello_world_display" instance="Magentochina\HelloWorld\Observer\ChangeDisplayText" />
 </event>
</config>

在这个文件中,在config元素下,我们定义了一个事件元素,名称是上面的事件名称。将执行此事件的类将在observer元素中通过实例属性定义。observer name被用来识别这个事件的其他observers。
这个events.xml事件的调度方法被调用在前端区域时,Magento将执行类
Magentochina\HelloWorld\Observer\ChangeDisplayText。请注意,我们放置events.xml在前端区域内,因此如果您在后台管理区域(如管理控制器)发送该事件,它就不会运行。
###观察者模式 Observer,为便于理解又被称为“发布-订阅模式”
现在,我们将创建一个类来执行上述事件。
文件:

app/code/Magentochina/HelloWorld/Observer/ChangeDisplayText.php

<?php
namespace Magentochina\HelloWorld\Observer;

class ChangeDisplayText implements \Magento\Framework\Event\ObserverInterface
{
  public function execute(\Magento\Framework\Event\Observer $observer)
{
 $displayText = $observer->getData('text');
 $displayText->setText('Execute event successfully.');

 return $this;
}
}

该类将实现ObserverInterface并声明execute方法。您可以通过这个简单的方法来了解它是如何工作的。
让我们刷新缓存并查看结果。
##Magento 2中所有的事件
###事件php文件

文件位置 事件名
Authorizenet/Controller/Directpost/Payment/Place.php checkout_directpost_placeOrder
Backend/Block/System/Store/Edit/AbstractForm.php adminhtml_store_edit_form_prepare_form
Backend/Block/Template.php adminhtml_block_html_before
Backend/Block/Widget/Grid.php backend_block_widget_grid_prepare_grid_before
Backend/Console/Command/CacheCleanCommand.php adminhtml_cache_flush_system
Backend/Console/Command/CacheFlushCommand.php adminhtml_cache_flush_all
Backend/Controller/Adminhtml/Cache/CleanImages.php clean_catalog_images_cache_after
Backend/Controller/Adminhtml/Cache/CleanMedia.php clean_media_cache_after
Backend/Controller/Adminhtml/Cache/CleanStaticFiles.php clean_static_files_cache_after
Backend/Controller/Adminhtml/Cache/FlushAll.php adminhtml_cache_flush_all
Backend/Controller/Adminhtml/Cache/FlushSystem.php adminhtml_cache_flush_system
Backend/Controller/Adminhtml/System/Design/Save.php theme_save_after
Backend/Controller/Adminhtml/System/Store/DeleteStorePost.php store_delete
Backend/Controller/Adminhtml/System/Store/Save.php store_group_save
Backend/Controller/Adminhtml/System/Store/Save.php NO_MATCH
Backend/Model/Auth.php backend_auth_user_login_success
Backend/Model/Auth.php backend_auth_user_login_failed
Backend/Model/Auth.php backend_auth_user_login_failed
Bundle/Block/Catalog/Product/View/Type/Bundle.php catalog_product_option_price_configuration_after
Bundle/Model/Product/Price.php prepare_catalog_product_collection_prices
Bundle/Model/Product/Price.php catalog_product_get_final_price
Bundle/Model/Product/Price.php catalog_product_get_final_price
Bundle/Model/ResourceModel/Indexer/Price.php catalog_product_prepare_index_select
Bundle/Pricing/Price/BundleSelectionPrice.php catalog_product_get_final_price
Catalog/Block/Adminhtml/Category/Tab/Attributes.php adminhtml_catalog_category_edit_prepare_form
Catalog/Block/Adminhtml/Category/Tabs.php adminhtml_catalog_category_tabs
Catalog/Block/Adminhtml/Category/Tree.php adminhtml_catalog_category_tree_is_moveable
Catalog/Block/Adminhtml/Category/Tree.php adminhtml_catalog_category_tree_can_add_root_category
Catalog/Block/Adminhtml/Category/Tree.php adminhtml_catalog_category_tree_can_add_sub_category
Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php product_attribute_form_build
Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php product_attribute_form_build_front_tab
Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php adminhtml_catalog_product_attribute_edit_frontend_prepare_form
Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php adminhtml_product_attribute_types
Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php product_attribute_form_build_main_tab
Catalog/Block/Adminhtml/Product/Attribute/Grid.php product_attribute_grid_build
Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Attributes.php adminhtml_catalog_product_edit_prepare_form
Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Attributes.php adminhtml_catalog_product_edit_element_types
Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php adminhtml_catalog_product_attribute_set_main_html_before
Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main.php adminhtml_catalog_product_attribute_set_toolbar_main_html_before
Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php adminhtml_catalog_product_form_prepare_excluded_field_list
Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Create.php adminhtml_catalog_product_edit_tab_attributes_create_html_before
Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes.php adminhtml_catalog_product_edit_prepare_form
Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes.php adminhtml_catalog_product_edit_element_types
Catalog/Block/Adminhtml/Product/Grid.php adminhtml_catalog_product_grid_prepare_massaction
Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php catalog_product_gallery_prepare_layout
Catalog/Block/Product/AbstractProduct.php catalog_block_product_status_display
Catalog/Block/Product/ListProduct.php catalog_block_product_list_collection
Catalog/Block/Product/ProductList/Upsell.php catalog_product_upsell
Catalog/Block/Product/View/Options.php catalog_product_option_price_configuration_after
Catalog/Block/Product/View.php catalog_product_view_config
Catalog/Block/Rss/Category.php rss_catalog_category_xml_callback
Catalog/Block/Rss/Product/NewProducts.php rss_catalog_new_xml_callback
Catalog/Block/Rss/Product/Special.php rss_catalog_special_xml_callback
Catalog/Block/ShortcutButtons.php shortcut_buttons_container
Catalog/Controller/Adminhtml/Category/Delete.php catalog_controller_category_delete
Catalog/Controller/Adminhtml/Category/Edit.php category_prepare_ajax_response
Catalog/Controller/Adminhtml/Category/Save.php catalog_category_prepare_save
Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php catalog_product_to_website_change
Catalog/Controller/Adminhtml/Product/Edit.php catalog_product_edit_action
Catalog/Controller/Adminhtml/Product/Gallery/Upload.php catalog_product_gallery_upload_image_after
Catalog/Controller/Adminhtml/Product/NewAction.php catalog_product_new_action
Catalog/Controller/Adminhtml/Product/Save.php controller_action_catalog_product_save_entity_after
Catalog/Controller/Category/View.php catalog_controller_category_init_after
Catalog/Controller/Product/Compare/Add.php catalog_product_compare_add_product
Catalog/Controller/Product/Compare/Remove.php catalog_product_compare_remove_product
Catalog/Helper/Product/View.php catalog_controller_product_view
Catalog/Helper/Product.php catalog_controller_product_init_before
Catalog/Helper/Product.php catalog_controller_product_init_after
Catalog/Model/Category.php _move_before
Catalog/Model/Category.php _move_after
Catalog/Model/Category.php category_move
Catalog/Model/Product/Action.php catalog_product_attribute_update_before
Catalog/Model/Product/Attribute/Source/Inputtype.php adminhtml_product_attribute_types
Catalog/Model/Product/Type/AbstractType.php NO_MATCH
Catalog/Model/Product/Type/Price.php catalog_product_get_final_price
Catalog/Model/Product.php _validate_before
Catalog/Model/Product.php _validate_after
Catalog/Model/Product.php catalog_product_is_salable_before
Catalog/Model/Product.php catalog_product_is_salable_after
Catalog/Model/ResourceModel/Category/Collection.php _load_before
Catalog/Model/ResourceModel/Category/Collection.php _load_after
Catalog/Model/ResourceModel/Category/Collection.php _add_is_active_filter
Catalog/Model/ResourceModel/Category/Flat/Collection.php _load_before
Catalog/Model/ResourceModel/Category/Flat/Collection.php _load_after
Catalog/Model/ResourceModel/Category/Flat/Collection.php _add_is_active_filter
Catalog/Model/ResourceModel/Category/Flat.php catalog_category_tree_init_inactive_category_ids
Catalog/Model/ResourceModel/Category/Flat.php catalog_category_flat_loadnodes_before
Catalog/Model/ResourceModel/Category/Tree.php catalog_category_tree_init_inactive_category_ids
Catalog/Model/ResourceModel/Category.php catalog_category_change_products
Catalog/Model/ResourceModel/Product/Collection.php catalog_prepare_price_select
Catalog/Model/ResourceModel/Product/Collection.php catalog_product_collection_load_after
Catalog/Model/ResourceModel/Product/Collection.php catalog_product_collection_before_add_count_to_categories
Catalog/Model/ResourceModel/Product/Collection.php catalog_product_collection_apply_limitations_after
Catalog/Model/ResourceModel/Product/Compare/Item/Collection.php catalog_product_compare_item_collection_clear
Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php prepare_catalog_product_index_select
Catalog/Model/ResourceModel/Product/Indexer/Eav/Decimal.php prepare_catalog_product_index_select
Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php prepare_catalog_product_index_select
Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php prepare_catalog_product_index_select
Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php prepare_catalog_product_index_select
Catalog/Model/ResourceModel/Product.php catalog_product_delete_after_done
Catalog/Model/Rss/Product/NotifyStock.php rss_catalog_notify_stock_collection_select
Catalog/Plugin/Model/Product/Action/UpdateAttributesFlushCache.php clean_cache_by_tags
CatalogImportExport/Model/Import/Product.php catalog_product_import_bunch_delete_after
CatalogImportExport/Model/Import/Product.php catalog_product_import_finish_before
CatalogImportExport/Model/Import/Product.php catalog_product_import_bunch_save_after
CatalogInventory/Model/Indexer/Stock/AbstractAction.php clean_cache_by_tags
CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Main.php adminhtml_promo_catalog_edit_tab_main_prepare_form
CatalogRule/Controller/Adminhtml/Promo/Catalog/Save.php adminhtml_controller_catalogrule_prepare_save
CatalogRule/Model/Indexer/AbstractIndexer.php clean_cache_by_tags
CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php catelogsearch_searchable_attributes_load_after
CatalogSearch/Model/Indexer/Fulltext/Action/Full.php catelogsearch_searchable_attributes_load_after
CatalogSearch/Model/ResourceModel/Fulltext.php catalogsearch_reset_search_result
Checkout/Block/QuoteShortcutButtons.php shortcut_buttons_container
Checkout/Controller/Cart/Add.php checkout_cart_add_product_complete
Checkout/Controller/Cart/UpdateItemOptions.php checkout_cart_update_item_complete
Checkout/Controller/Onepage/SaveOrder.php checkout_controller_onepage_saveOrder
Checkout/Controller/Onepage/Success.php checkout_onepage_controller_success_action
Checkout/Helper/Data.php checkout_allow_guest
Checkout/Model/Cart.php checkout_cart_product_add_after
Checkout/Model/Cart.php checkout_cart_update_items_before
Checkout/Model/Cart.php checkout_cart_update_items_after
Checkout/Model/Cart.php checkout_cart_save_before
Checkout/Model/Cart.php checkout_cart_save_after
Checkout/Model/Cart.php checkout_cart_product_update_after
Checkout/Model/Session.php custom_quote_process
Checkout/Model/Session.php checkout_quote_init
Checkout/Model/Session.php load_customer_quote_before
Checkout/Model/Session.php checkout_quote_destroy
Checkout/Model/Session.php restore_quote
Checkout/Model/Type/Onepage.php checkout_type_onepage_save_order_after
Checkout/Model/Type/Onepage.php checkout_submit_all_after
Cms/Block/Adminhtml/Page/Edit/Tab/Content.php adminhtml_cms_page_edit_tab_content_prepare_form
Cms/Block/Adminhtml/Page/Edit/Tab/Design.php adminhtml_cms_page_edit_tab_design_prepare_form
Cms/Block/Adminhtml/Page/Edit/Tab/Main.php adminhtml_cms_page_edit_tab_main_prepare_form
Cms/Block/Adminhtml/Page/Edit/Tab/Meta.php adminhtml_cms_page_edit_tab_meta_prepare_form
Cms/Controller/Adminhtml/Page/Delete.php adminhtml_cmspage_on_delete
Cms/Controller/Adminhtml/Page/Delete.php adminhtml_cmspage_on_delete
Cms/Controller/Adminhtml/Page/Save.php cms_page_prepare_save
Cms/Controller/Router.php cms_controller_router_match_before
Cms/Helper/Page.php cms_page_render
Cms/Helper/Wysiwyg/Images.php cms_wysiwyg_images_static_urls_allowed
Config/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php adminhtml_system_config_advanced_disableoutput_render_before
Config/Model/Config.php NO_MATCH
ConfigurableProduct/Model/Product/Validator/Plugin.php catalog_product_validate_variations_before
Cookie/Controller/Index/NoCookies.php controller_action_nocookies
CurrencySymbol/Model/System/Currencysymbol.php admin_system_config_changed_section_currency_before_reinit
CurrencySymbol/Model/System/Currencysymbol.php admin_system_config_changed_section_currency
Customer/Block/Adminhtml/Edit/Tab/Carts.php adminhtml_block_html_before
Customer/Controller/Account/CreatePost.php customer_register_success
Customer/Controller/Adminhtml/Index/Save.php adminhtml_customer_prepare_save
Customer/Controller/Adminhtml/Index/Save.php adminhtml_customer_save_after
Customer/Model/AccountManagement.php customer_customer_authenticated
Customer/Model/AccountManagement.php customer_data_object_login
Customer/Model/Address/AbstractAddress.php customer_address_format
Customer/Model/Customer.php customer_customer_authenticated
Customer/Model/Customer.php customer_validate
Customer/Model/ResourceModel/CustomerRepository.php customer_save_after_data_object
Customer/Model/Session.php customer_session_init
Customer/Model/Session.php customer_login
Customer/Model/Session.php customer_data_object_login
Customer/Model/Session.php customer_login
Customer/Model/Session.php customer_data_object_login
Customer/Model/Session.php customer_logout
Customer/Model/Visitor.php visitor_init
Customer/Model/Visitor.php visitor_activity_save
Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php adminhtml_block_eav_attribute_edit_form_init
Eav/Model/Entity/Collection/AbstractCollection.php eav_collection_abstract_load_before
GiftMessage/Block/Message/Inline.php gift_options_prepare_items
GroupedProduct/Model/ResourceModel/Product/Indexer/Price/Grouped.php catalog_product_prepare_index_select
Indexer/Model/Processor/InvalidateCache.php clean_cache_after_reindex
Multishipping/Controller/Checkout/ShippingPost.php checkout_controller_multishipping_shipping_post
Multishipping/Controller/Checkout/Success.php multishipping_checkout_controller_success_action
Multishipping/Model/Checkout/Type/Multishipping.php checkout_type_multishipping_set_shipping_items
Multishipping/Model/Checkout/Type/Multishipping.php checkout_type_multishipping_create_orders_single
Multishipping/Model/Checkout/Type/Multishipping.php checkout_submit_all_after
Multishipping/Model/Checkout/Type/Multishipping.php checkout_multishipping_refund_all
PageCache/Model/Cache/Type.php adminhtml_cache_refresh_type
PageCache/Model/Layout/DepersonalizePlugin.php depersonalize_clear_session
Payment/Block/Form/Cc.php payment_form_block_to_html_before
Payment/Model/Cart.php payment_cart_collect_items_and_amounts
Payment/Model/Method/AbstractMethod.php payment_method_is_active
Payment/Model/Method/Adapter.php payment_method_is_active
Payment/Model/Method/Adapter.php payment_method_assign_data_
Paypal/Controller/Express/AbstractExpress/PlaceOrder.php paypal_express_place_order_success
Persistent/Controller/Index/UnsetCookie.php persistent_session_expired
Persistent/Observer/CheckExpirePersistentQuoteObserver.php persistent_session_expired
Quote/Model/Cart/Totals/ItemConverter.php items_additional_data
Quote/Model/Quote/Address/ToOrder.php sales_convert_quote_to_order
Quote/Model/Quote/Item.php sales_quote_item_qty_set_after
Quote/Model/Quote/Item.php sales_quote_item_set_product
Quote/Model/Quote/Payment.php _import_data_before
Quote/Model/Quote/TotalsCollector.php sales_quote_collect_totals_before
Quote/Model/Quote/TotalsCollector.php sales_quote_collect_totals_after
Quote/Model/Quote/TotalsCollector.php sales_quote_address_collect_totals_before
Quote/Model/Quote/TotalsCollector.php sales_quote_address_collect_totals_after
Quote/Model/Quote.php sales_quote_remove_item
Quote/Model/Quote.php sales_quote_add_item
Quote/Model/Quote.php sales_quote_product_add_after
Quote/Model/Quote.php _merge_before
Quote/Model/Quote.php _merge_after
Quote/Model/QuoteManagement.php checkout_submit_before
Quote/Model/QuoteManagement.php checkout_submit_all_after
Quote/Model/QuoteManagement.php sales_model_service_quote_submit_before
Quote/Model/QuoteManagement.php sales_model_service_quote_submit_success
Quote/Model/QuoteManagement.php sales_model_service_quote_submit_failure
Quote/Model/ResourceModel/Quote/Address/Collection.php _load_after
Quote/Model/ResourceModel/Quote/Item/Collection.php prepare_catalog_product_collection_prices
Quote/Model/ResourceModel/Quote/Item/Collection.php sales_quote_item_collection_products_after_load
Reports/Block/Adminhtml/Grid.php adminhtml_widget_grid_filter_collection
Reports/Model/ResourceModel/Order/Collection.php sales_prepare_amount_expression
Review/Controller/Product.php review_controller_product_init_before
Review/Controller/Product.php review_controller_product_init
Review/Controller/Product.php review_controller_product_init_after
Review/Model/ResourceModel/Rating/Collection.php rating_rating_collection_load_before
Review/Model/ResourceModel/Review/Collection.php review_review_collection_load_before
Review/Model/Rss.php rss_catalog_review_collection_select
Sales/Block/Adminhtml/Reorder/Renderer/Action.php adminhtml_customer_orders_add_action_renderer
Sales/Controller/Adminhtml/Order/AddressSave.php admin_sales_order_address_update
Sales/Controller/Adminhtml/Order/Create.php adminhtml_sales_order_create_process_data_before
Sales/Controller/Adminhtml/Order/Create.php adminhtml_sales_order_create_process_data
Sales/Controller/Adminhtml/Order/CreditmemoLoader.php adminhtml_sales_order_creditmemo_register_before
Sales/Model/AdminOrder/Create.php sales_convert_order_to_quote
Sales/Model/AdminOrder/Create.php sales_convert_order_item_to_quote_item
Sales/Model/AdminOrder/Create.php checkout_submit_all_after
Sales/Model/Config/Backend/Email/AsyncSending.php sales_email_general_async_sending
Sales/Model/Config/Backend/Grid/AsyncIndexing.php dev_grid_async_indexing
Sales/Model/Order/Address/Renderer.php customer_address_format
Sales/Model/Order/Email/Sender/CreditmemoCommentSender.php email_creditmemo_comment_set_template_vars_before
Sales/Model/Order/Email/Sender/CreditmemoSender.php email_creditmemo_set_template_vars_before
Sales/Model/Order/Email/Sender/InvoiceCommentSender.php email_invoice_comment_set_template_vars_before
Sales/Model/Order/Email/Sender/InvoiceSender.php email_invoice_set_template_vars_before
Sales/Model/Order/Email/Sender/OrderCommentSender.php email_order_comment_set_template_vars_before
Sales/Model/Order/Email/Sender/OrderSender.php email_order_set_template_vars_before
Sales/Model/Order/Email/Sender/ShipmentCommentSender.php email_shipment_comment_set_template_vars_before
Sales/Model/Order/Email/Sender/ShipmentSender.php email_shipment_set_template_vars_before
Sales/Model/Order/Invoice.php sales_order_invoice_pay
Sales/Model/Order/Invoice.php sales_order_invoice_cancel
Sales/Model/Order/Invoice.php sales_order_invoice_register
Sales/Model/Order/Item.php sales_order_item_cancel
Sales/Model/Order/Payment/Operations/CaptureOperation.php sales_order_payment_capture
Sales/Model/Order/Payment/Transaction.php _html_txn_id
Sales/Model/Order/Payment.php sales_order_payment_place_start
Sales/Model/Order/Payment.php sales_order_payment_place_end
Sales/Model/Order/Payment.php sales_order_payment_pay
Sales/Model/Order/Payment.php sales_order_payment_cancel_invoice
Sales/Model/Order/Payment.php sales_order_payment_void
Sales/Model/Order/Payment.php sales_order_payment_refund
Sales/Model/Order/Payment.php sales_order_payment_cancel_creditmemo
Sales/Model/Order/Payment.php sales_order_payment_cancel
Sales/Model/Order/Status.php sales_order_status_unassign
Sales/Model/Order.php sales_order_place_before
Sales/Model/Order.php sales_order_place_after
Sales/Model/Order.php order_cancel_after
Sales/Model/ResourceModel/Attribute.php _save_attribute_before
Sales/Model/ResourceModel/Attribute.php _save_attribute_after
Sales/Model/ResourceModel/Order/Address/Collection.php _load_after
Sales/Model/ResourceModel/Order/Collection/AbstractCollection.php _set_sales_order
Sales/Model/ResourceModel/Sale/Collection.php sales_sale_collection_query_before
Sales/Model/Rss/NewOrder.php rss_order_new_collection_select
Sales/Model/Service/CreditmemoService.php sales_order_creditmemo_cancel
Sales/Model/Service/CreditmemoService.php sales_order_creditmemo_refund
Sales/Model/Service/OrderService.php sales_order_state_change_before
SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Actions.php adminhtml_block_salesrule_actions_prepareform
SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Form.php adminhtml_promo_quote_edit_tab_coupons_form_prepare_form
SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Main.php adminhtml_promo_quote_edit_tab_main_prepare_form
SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php adminhtml_block_promo_widget_chooser_prepare_collection
SalesRule/Controller/Adminhtml/Promo/Quote/Save.php adminhtml_controller_salesrule_prepare_save
SalesRule/Model/Quote/Discount.php sales_quote_address_discount_item
SalesRule/Model/Quote/Discount.php sales_quote_address_discount_item
SalesRule/Model/Rule/Condition/Combine.php salesrule_rule_condition_combine
SalesRule/Model/Rule.php salesrule_rule_get_coupon_types
SalesRule/Model/RulesApplier.php salesrule_validator_process
Search/Controller/Adminhtml/Term/Report.php on_view_report
SendFriend/Controller/Product/Send.php sendfriend_product
Store/Model/Address/Renderer.php store_address_format
Swatches/Controller/Adminhtml/Iframe/Show.php swatch_gallery_upload_image_after
Tax/Controller/Adminhtml/Tax/IgnoreTaxNotification.php adminhtml_cache_refresh_type
Tax/Model/Calculation/Rate.php tax_settings_change_after
Tax/Model/Calculation/Rate.php tax_settings_change_after
Tax/Model/Calculation/Rate.php tax_settings_change_after
Tax/Model/Calculation/Rule.php tax_settings_change_after
Tax/Model/Calculation/Rule.php tax_settings_change_after
Tax/Model/Calculation.php tax_rate_data_fetch
Theme/Block/Html/Topmenu.php page_block_html_topmenu_gethtml_before
Theme/Block/Html/Topmenu.php page_block_html_topmenu_gethtml_after
Theme/Model/Config.php assign_theme_to_stores_after
Theme/Observer/CheckThemeIsAssignedObserver.php assigned_theme_changed
Theme/Setup/InstallData.php theme_registration_from_filesystem
User/Block/Role.php permissions_role_html_before
User/Controller/Adminhtml/User/Role/SaveRole.php admin_permissions_role_prepare_save
User/Model/User.php admin_user_authenticate_before
User/Model/User.php admin_user_authenticate_after
Wishlist/Block/Customer/Wishlist/Item/Options.php product_option_renderer_init
Wishlist/Controller/Index/Add.php wishlist_add_product
Wishlist/Controller/Index/Send.php wishlist_share
Wishlist/Controller/Index/UpdateItemOptions.php wishlist_update_item
Wishlist/Helper/Data.php wishlist_items_renewed
Wishlist/Model/ResourceModel/Item/Collection.php wishlist_item_collection_products_after_load
Wishlist/Model/Rss/Wishlist.php rss_wishlist_xml_callback
Wishlist/Model/Wishlist.php wishlist_add_item
Wishlist/Model/Wishlist.php wishlist_product_add_after
lib/internal/Magento/Framework/App/Action/Action.php controller_action_predispatch
lib/internal/Magento/Framework/App/Action/Action.php controller_action_predispatch_
lib/internal/Magento/Framework/App/Action/Action.php controller_action_predispatch_
lib/internal/Magento/Framework/App/Action/Action.php controller_action_postdispatch_
lib/internal/Magento/Framework/App/Action/Action.php controller_action_postdispatch_
lib/internal/Magento/Framework/App/Action/Action.php controller_action_postdispatch
lib/internal/Magento/Framework/App/Cron.php default
lib/internal/Magento/Framework/App/FrontController.php NO_MATCH
lib/internal/Magento/Framework/App/Http.php NO_MATCH
lib/internal/Magento/Framework/App/Http.php controller_front_send_response_before
lib/internal/Magento/Framework/App/View.php controller_action_layout_render_before
lib/internal/Magento/Framework/App/View.php controller_action_layout_render_before_
lib/internal/Magento/Framework/Controller/Noroute/Index.php controller_action_noroute
lib/internal/Magento/Framework/Data/AbstractSearchResult.php abstract_search_result_load_before
lib/internal/Magento/Framework/Data/AbstractSearchResult.php _load_before
lib/internal/Magento/Framework/Data/AbstractSearchResult.php abstract_search_result_load_after
lib/internal/Magento/Framework/Data/AbstractSearchResult.php _load_after
lib/internal/Magento/Framework/DataObject/Copy.php NO_MATCH
lib/internal/Magento/Framework/Event/Collection.php NO_MATCH
lib/internal/Magento/Framework/Event/Manager.php NO_MATCH
lib/internal/Magento/Framework/Event/Observer/Collection.php NO_MATCH
lib/internal/Magento/Framework/Event.php NO_MATCH
lib/internal/Magento/Framework/Locale/Currency.php currency_display_options_forming
lib/internal/Magento/Framework/Message/Manager.php session_abstract_clear_messages
lib/internal/Magento/Framework/Message/Manager.php session_abstract_add_message
lib/internal/Magento/Framework/Model/AbstractModel.php model_load_before
lib/internal/Magento/Framework/Model/AbstractModel.php _load_before
lib/internal/Magento/Framework/Model/AbstractModel.php model_load_after
lib/internal/Magento/Framework/Model/AbstractModel.php _load_after
lib/internal/Magento/Framework/Model/AbstractModel.php model_save_commit_after
lib/internal/Magento/Framework/Model/AbstractModel.php _save_commit_after
lib/internal/Magento/Framework/Model/AbstractModel.php model_save_before
lib/internal/Magento/Framework/Model/AbstractModel.php _save_before
lib/internal/Magento/Framework/Model/AbstractModel.php model_save_after
lib/internal/Magento/Framework/Model/AbstractModel.php clean_cache_by_tags
lib/internal/Magento/Framework/Model/AbstractModel.php _save_after
lib/internal/Magento/Framework/Model/AbstractModel.php model_delete_before
lib/internal/Magento/Framework/Model/AbstractModel.php _delete_before
lib/internal/Magento/Framework/Model/AbstractModel.php model_delete_after
lib/internal/Magento/Framework/Model/AbstractModel.php clean_cache_by_tags
lib/internal/Magento/Framework/Model/AbstractModel.php _delete_after
lib/internal/Magento/Framework/Model/AbstractModel.php model_delete_commit_after
lib/internal/Magento/Framework/Model/AbstractModel.php _delete_commit_after
lib/internal/Magento/Framework/Model/AbstractModel.php _clear
lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php core_collection_abstract_load_before
lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php _load_before
lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php core_collection_abstract_load_after
lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php _load_after
lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/RelationComposite.php _process_relation
lib/internal/Magento/Framework/View/Element/AbstractBlock.php view_block_abstract_to_html_before
lib/internal/Magento/Framework/View/Element/Messages.php view_message_block_render_grouped_html_after
lib/internal/Magento/Framework/View/Layout/Builder.php layout_load_before
lib/internal/Magento/Framework/View/Layout/Builder.php layout_generate_blocks_before
lib/internal/Magento/Framework/View/Layout/Builder.php layout_generate_blocks_after
lib/internal/Magento/Framework/View/Layout/Generator/Block.php core_layout_block_create_after
lib/internal/Magento/Framework/View/Layout.php core_layout_render_element
lib/internal/Magento/Framework/View/Result/Layout.php layout_render_before
lib/internal/Magento/Framework/View/Result/Layout.php layout_render_before_
###Magento2 javascript 事件,JavaScript Varien Events
文件位置 事件名
lib/web/mage/adminhtml/form.js formSubmit
lib/web/mage/adminhtml/form.js address_country_changed
lib/web/mage/adminhtml/grid.js gridRowClick
lib/web/mage/adminhtml/grid.js gridRowDblClick
lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js tinymceSubmit
lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js tinymcePaste
lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js tinymceBeforeSetContent
lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js tinymceSetContent
lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js tinymceSaveContent
lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js tinymceChange
lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js tinymceExecCommand
lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js open_browser_callback
lib/web/mage/adminhtml/wysiwyg/widget.js tinymceChange

####更多信息可以查看Magento2官方开发文档关于Magento2事件部分.

####本教程翻译自mageplaza,如果你想查看完整的教程,请点击这里.译者:西帅
####如果觉得本站翻译得内容对您有帮助,又没有时间帮助翻译回馈社区.请打赏我们,您的支持是我们的动力:

####转载说明:非常欢迎转载,但是必须保证文章的完整性并附上原文地址和翻译原文的地址,保证阅读者不会产生歧义.