Create events from the Admin
This feature is available only in Adobe Commerce as a Cloud Service (ACCS).
In addition to the available REST endpoints for event subscriptions, Adobe Commerce as a Cloud Service also supports managing events through the Admin.
View event subscriptions
In the Admin, select System > Events > Events Subscriptions to display the Events Subscriptions grid page.
The rows of this grid show configuration settings for all event subscriptions, both enabled and disabled.
Create a new event subscription
Click Add New Subscription from the grid page to display the form for creating a new event subscription.
The Event subscription settings configuration panel contains the following fields:
Field | Description |
---|---|
Event Name | Select one of the supported Commerce event names from the dropdown. |
Event Name Alias | A unique alias name for the event. An alias is required for events that have rules configured. |
Event Provider | Select the event provider to which the event should be delivered. If a workspace configuration is set for the provider, event metadata will be created and linked to the provider when the event subscription is saved. |
Is Enabled | Indicates whether the event is enabled. Commerce does not emit disabled events. |
Priority | Indicates whether the event has priority status. Priority events are sent within a second, whereas non-priority events can take up to 59 seconds to send. |
Configure event subscription fields
The Event Subscription Fields configuration panel allows you to define the fields of the event payload to transmit from Commerce. The name provides the path to the field in the event payload.
For each event you register, you must define which fields to transmit to your App Builder application. The payload of an event can be massive. In addition, some events include sensitive or PCI compliance data by default. The payload of the observer.catalog_product_save_after
event is similar to the following:
Copied to your clipboard{"event":{"data":{"value":{"_edit_mode":true,"store_id":"0","entity_id":"3","attribute_set_id":"4","type_id":"simple","sku":"test2","has_options":false,"required_options":false,"created_at":"2022-07-28 14:13:40","updated_at":"2022-09-06 20:37:25","row_id":"3","created_in":"1","updated_in":"2147483647","name":"test2","meta_title":"test2","meta_description":"test2 ","page_layout":"product-full-width","options_container":"container2","url_key":"test2","msrp_display_actual_price_type":"0","gift_message_available":"2","gift_wrapping_available":"2","is_returnable":"2","status":"1","visibility":"4","tax_class_id":"2","price":"123.000000","meta_keyword":"test2","options":[],"media_gallery":{"images":[],"values":[]},"tier_price":[],"tier_price_changed":0,"quantity_and_stock_status":{"is_in_stock":"1","qty":"333"},"category_ids":["4"],"is_salable":1,"stock_data":{"item_id":"3","product_id":"3","stock_id":"1","qty":"333","min_qty":"0","use_config_min_qty":"1","is_qty_decimal":"0","backorders":"0","use_config_backorders":"1","min_sale_qty":"1","use_config_min_sale_qty":"1","max_sale_qty":"10000","use_config_max_sale_qty":"1","is_in_stock":"1","notify_stock_qty":"1","use_config_notify_stock_qty":"1","manage_stock":"1","use_config_manage_stock":"1","stock_status_changed_auto":"0","use_config_qty_increments":"1","qty_increments":"1","use_config_enable_qty_inc":"1","enable_qty_increments":"0","is_decimal_divided":0,"website_id":"0","deferred_stock_update":"0","use_config_deferred_stock_update":"1","type_id":"simple","min_qty_allowed_in_shopping_cart":[]},"use_config_gift_message_available":"1","use_config_gift_wrapping_available":"1","current_product_id":"3","affect_product_custom_options":"1","current_store_id":"0","product_has_weight":"1","is_new":"0","website_ids":{"1":"1"},"url_key_create_redirect":"test2","ignore_links_flag":false,"can_save_custom_options":true,"save_rewrites_history":true,"can_save_bundle_selections":false,"is_custom_option_changed":true,"parent_id":0,"special_from_date_is_formated":true,"custom_design_from_is_formated":true,"news_from_date_is_formated":true,"news_to_date_is_formated":true,"is_changed_categories":false,"is_changed_websites":false,"force_reindex_eav_required":true},"_metadata":{"commerceEdition":"Adobe Commerce","commerceVersion":"2.4.6-beta5","eventsClientVersion":"1.0.1","storeId":"0","websiteId":"1","storeGroupId":"0"},"source":"demo.demo"}}}
You define an array of fields to transmit in your configuration file. Specify any field within an event's value
object to ensure it is transmitted to an application. If the field is part of a secondary object, such as stock_data
in the above example, use the format <object-name>.field
. For example: stock_data.product_id
.
If you do not specify any fields, Commerce sends the entire event payload. Adobe recommends sending a limited number of fields per event. If you send all fields, you increase the risk of including sensitive or PCI compliance data in the event. In addition, specifying only the fields that are applicable to your business case is recommended for optimal performance and cost effectiveness.
The following example shows how three fields can be configured for the observer.catalog_product_save_after
event:
Copied to your clipboardName: entity_idName: skuName: is_new
The contents of an observer.catalog_product_save_after
event are similar to the following:
Copied to your clipboard{"entity_id": "3","sku": "test2","is_new": "0"}
Array of nested objects
When the payload contains an array of objects, use the following construction to register specific fields from that array:
Copied to your clipboard<object_name>[].<field_name>
For example, the payload of the observer.sales_order_invoice_save_after
event contains a top-level items[]
array. In this case, the array contains details about two individual products.
Copied to your clipboard{"event": {"data": {"value": {"order_id": "8","store_id": "1","customer_id": null,"billing_address_id": "16","shipping_address_id": "15","global_currency_code": "USD","base_currency_code": "USD","store_currency_code": "USD","order_currency_code": "USD","store_to_base_rate": "0.0000","store_to_order_rate": "0.0000","base_to_global_rate": "1.0000","base_to_order_rate": "1.0000","discount_description": null,"items": [{"order_item_id": "8","product_id": "22","sku": "simple-product-2","name": "Simple Product 2","description": null,"price": 200,"base_price": "200.0000","base_cost": null,"price_incl_tax": "200.0000","base_price_incl_tax": "200.0000","extension_attributes": {},"weee_tax_applied": "[]","weee_tax_applied_amount": null,"weee_tax_applied_row_amount": 0,"base_weee_tax_applied_amount": null,"base_weee_tax_applied_row_amnt": null,"weee_tax_disposition": null,"base_weee_tax_disposition": null,"weee_tax_row_disposition": 0,"base_weee_tax_row_disposition": 0,"qty": "3.000000","invoice": {},"parent_id": null,"store_id": "1","row_total": 600,"base_row_total": 600,"row_total_incl_tax": 600,"base_row_total_incl_tax": 600,"tax_amount": 0,"base_tax_amount": 0,"discount_tax_compensation_amount": 0,"base_discount_tax_compensation_amount": 0,"base_weee_tax_applied_row_amount": 0},{"order_item_id": "9","product_id": "21","sku": "simple-product-1","name": "Simple Product 1","description": null,"price": 100,"base_price": "100.0000","base_cost": null,"price_incl_tax": "100.0000","base_price_incl_tax": "100.0000","extension_attributes": {},"weee_tax_applied": "[]","weee_tax_applied_amount": null,"weee_tax_applied_row_amount": 0,"base_weee_tax_applied_amount": null,"base_weee_tax_applied_row_amnt": null,"weee_tax_disposition": null,"base_weee_tax_disposition": null,"weee_tax_row_disposition": 0,"base_weee_tax_row_disposition": 0,"qty": "5.000000","invoice": {},"parent_id": null,"store_id": "1","row_total": 500,"base_row_total": 500,"row_total_incl_tax": 500,"base_row_total_incl_tax": 500,"tax_amount": 0,"base_tax_amount": 0,"discount_tax_compensation_amount": 0,"base_discount_tax_compensation_amount": 0,"base_weee_tax_applied_row_amount": 0}],"total_qty": 8,"subtotal": 1100,"base_subtotal": 1100,"subtotal_incl_tax": 1100,"base_subtotal_incl_tax": 1100,"grand_total": 1100,"base_grand_total": 1100,"discount_amount": 0,"base_discount_amount": 0,"tax_amount": 0,"base_tax_amount": 0,"discount_tax_compensation_amount": 0,"base_discount_tax_compensation_amount": 0,"base_cost": 0,"base_gift_cards_amount": 0,"gift_cards_amount": 0,"can_void_flag": false,"state": 2,"increment_id": "000000013","entity_id": "13","id": "13","created_at": "2023-04-06 18:36:18","updated_at": "2023-04-06 18:36:18"}}}}
To register the top-level order_id
field and the sku
and qty
of each product, define the subscription as follows:
Copied to your clipboardName: order_idName: items[].skuName: items[].qty
The contents of the transmitted event are similar to the following:
Copied to your clipboard{"order_id": "8","items": [{"sku": "simple-product-2","qty": "3.000000"},{"sku": "simple-product-1","qty": "5.000000"}]}
Configure event subscription rules
You may decide that you want Adobe I/O Events for Adobe Commerce to notify the client application when certain conditions occur. For example, by default, if you register an event that tracks the remaining quantity of a product, the eventing service sends that information to your client application each time Commerce emits the event. However, you might be interested in the remaining quantity only when it reaches a specific threshold, such as 20 units. Conditional events allow you to define exactly when to send events to your application. Otherwise, the client application must include code to filter out the unimportant and unnecessary data.
A conditional event acts as an extension of a custom or native Commerce event. You must specify the source, or parent, event and define one or more rules that evaluate the data that is present in the parent event payload. If all the individual rules defined in a conditional event evaluate as true, then the eventing service sends the conditional event to the application. If one or more rules evaluate as false, the service sends neither the parent event nor the conditional event, unless the parent has been subscribed separately, without any rules.
All conditional events contain the following information:
A unique name for the conditional event.
The name of the parent event. You must attach a conditional event to a specific registered event.
One or more rules.
Each rule contains the following:
A field that is defined in the parent event.
An operator, which is represented as a comparison statement between the value supplied in the parent event's payload and the threshold value.
The operator must be one of the following:
Operator Description greaterThan
Checks whether the value supplied in the payload of the event is greater than a specified value. Applicable for integer and float data types.lessThan
Checks whether the payload value is less than a specified value. Applicable for integer and float data types.equal
Checks whether the payload value matches the specified value. For Boolean data types, use1
to compare totrue
and0
to compare tofalse
.regex
A regular expression that checks for matches. The specified value must be compatible with the regular expression match.in
Checks whether the payload value is one of multiple specified values. The value must be a comma-separated list. You do not need to provide additional escape characters.The value to compare against. When you assign the
regex
operator, you must delimit the regular expression value with valid characters, such as forward slashes (/). For example,/^TV .*/i
, which checks whether the string starts with the stringTV
, ignoring the case of the letters.
Example
Copied to your clipboardField: qtyOperator: lessThanValue: 20Field: category_idOperator: inValue: 3,4,5Field: nameOperator: regexValue: /^TV .*/iField: category.store_idOperator: inValue: 1,2
Events Subscriptions grid actions
Click Select > Edit in the Action column of an event subscription's row to display a form for editing the subscription.
Click Select > Delete in the Action column to delete an event subscription.