Context values
You can add to the event payload values from the application context. It allows you to include data that is not part of the event by default but is crucial for your integration.
The following contexts are supported:
| Context | Context class | Description |
|---|---|---|
context_checkout_session | Magento\Checkout\Model\Session | Contains information about the current checkout session, including the current quote. |
context_customer_session | Magento\Customer\Model\Session | Contains information about the current customer session, including the current customer. |
context_application_state | Magento\Framework\App\State | Contains information about current application mode and area code. |
context_scope_config | Magento\Framework\App\Config\ScopeConfigInterface | Provides access to the configuration settings for different scopes. |
context_http_request | Magento\Framework\App\Request\Http | Provides access to the current HTTP request data. |
context_staging | Magento\Staging\Model\VersionManager | Provides access to the staging version management functionalities. |
context_store | Magento\Store\Model\StoreManagerInterface | Provides access to store-related information such as website, store, and store view. |
Checkout session context
The context_checkout_session context retrieves information about the current checkout session. You can use this context to access the information about the current quote.
Copied to your clipboard<fields><field name="quote.id" source="context_checkout_session.get_quote.get_id" /><field name="quote.sub_total" source="context_checkout_session.get_quote.get_subtotal" /><field name="quote.customer_group_id" source="context_checkout_session.get_quote.get_customer_group_id" /></fields>
Copied to your clipboardEvent FieldsName: quote.idSource: context_checkout_session.get_quote.get_idActive: YesName: quote.sub_totalSource: context_checkout_session.get_quote.get_subtotalActive: YesName: quote.customer_group_idSource: context_checkout_session.get_quote.get_customer_group_idActive: Yes
Your event payload will contain the following data:
Copied to your clipboard{"quote": {"id": "66","sub_total": "600.0000","customer_group_id": "0"}}
If the quote does not exist in the current session, the values will be set to null.
Customer session context
The context_customer_session retrieves information about the current customer session. You can use this context to access the information about the current customer.
Copied to your clipboard<fields><field name="customer.id" source="context_customer_session.get_customer.get_id" /><field name="customer.email" source="context_customer_session.get_customer.get_email" /><field name="customer.group_id" source="context_customer_session.get_customer.get_group_id" /></fields>
Copied to your clipboardEvent FieldsName: customer.idSource: context_customer_session.get_customer.get_idActive: YesName: customer.emailSource: context_customer_session.get_customer.get_emailActive: YesName: customer.group_idSource: context_customer_session.get_customer.get_group_idActive: Yes
Your event payload will contain the following data:
Copied to your clipboard{"customer": {"id": "123","email": "test@example.com","group_id": "2"}}
If the customer is not logged in, the values will be set to null.
Application state context
The context_application_state context retrieves information about the current application state.
Copied to your clipboard<fields><field name="app_area_code" source="context_application_state.get_area_code" /><field name="app_mode" source="context_application_state.get_mode" /></fields>
Copied to your clipboardEvent FieldsName: app_area_codeSource: context_application_state.get_area_codeActive: YesName: app_modeSource: context_application_state.get_modeActive: Yes
Your event payload will contain the following data:
Copied to your clipboard{"app_area_code": "webapi_rest","app_mode": "production"}
The context_application_state.get_area_code field returns the area code of the application where event was triggered. The possible values are global, frontend, adminhtml, crontab, webapi_rest, webapi_soap, graphql. This value can be used to determine the context of the request and to apply specific logic based on the area code.
The context_application_state.get_mode field returns the current application mode. The possible values are default, developer, and production.
Scope config context
The context_scope_config context retrieves information from the configuration scope. If your integration depends on a specific configuration value, you can use this context to retrieve the value from the configuration.
The following example retrieves the general/locale/timezone and general/locale/code configuration values from the default scope.
Copied to your clipboard<fields><field name="config.timezone" source="context_scope_config.get_value{general/locale/timezone:default}" /><field name="config.local" source="context_scope_config.get_value{general/locale/code:default}" /></fields>
Copied to your clipboardEvent FieldsName: config.timezoneSource: context_scope_config.get_value{general/locale/timezone:default}Active: YesName: config.localSource: context_scope_config.get_value{general/locale/code:default}Active: Yes
Your event payload will contain the following data:
Copied to your clipboard{"config": {"timezone": "America/Chicago","local": "en_US"}}
HTTP request context
The context_http_request context retrieves information about the current HTTP request.
Copied to your clipboard<fields><field name="request.path_info" source="context_http_request.get_path_info" /><field name="request.base_path" source="context_http_request.get_base_path" /><field name="request.front_name" source="context_http_request.get_front_name" /></fields>
Copied to your clipboardEvent FieldsName: request.path_infoSource: context_http_request.get_path_infoActive: YesName: request.base_pathSource: context_http_request.get_base_pathActive: YesName: request.front_nameSource: context_http_request.get_front_nameActive: Yes
Your event payload will contain the following data:
Copied to your clipboard{"request": {"path_info": "/rest/default/V1/guest-carts/estimate-shipping-methods","base_path": "/","front_name": "rest"}}
Staging context
The context_staging context retrieves information about the current staging version.
Copied to your clipboard<fields><field name="staging.version" source="context_staging.get_version" /><field name="staging.current_version" source="context_staging.get_current_version" /></fields>
Copied to your clipboardEvent FieldsName: staging.versionSource: context_staging.get_versionActive: YesName: staging.current_versionSource: context_staging.get_current_versionActive: Yes
Your event payload will contain the following data:
Copied to your clipboard{"staging": {"version": {"id": 1},"current_version": {"id": 1}}}
Store context
The context_store context retrieves information about the current store.
io_events.xml (PaaS)
Copied to your clipboard<fields><field name="store.store_id" source="context_store.get_store.get_id" /><field name="store.store_data" source="context_store.get_store" /><field name="store.website_data" source="context_store.get_website" /><field name="store.store_group_data" source="context_store.get_group" /></fields>
Admin (SaaS)
Copied to your clipboardEvent FieldsName: store.store_idSource: context_store.get_store.get_idActive: YesName: store.store_dataSource: context_store.get_storeActive: YesName: store.website_dataSource: context_store.get_websiteActive: YesName: store.store_group_dataSource: context_store.get_groupActive: Yes
Your event payload will contain the following data:
Copied to your clipboard{"store": {"store_id": "1","store_data": {"store_id": "1","code": "default","website_id": "1","group_id": "1","name": "Default Store View","sort_order": "0","is_active": "1","available_currency_codes": ["USD"],"base_currency": {"currency_code": "USD"},"current_currency": {"currency_code": "USD"}},"website_data": {"website_id": "1","code": "base","name": "Main Website","sort_order": "0","default_group_id": "1","is_default": "1"},"store_group_data": {"group_id": "1","website_id": "1","name": "Main Website Store","root_category_id": "2","default_store_id": "1","code": "main_website_store"}}}

