Skip to content

Commit a9de4dc

Browse files
authored
Merge pull request AdobeDocs#394 from AdobeDocs/events-badging
Add badging for eventing
2 parents 44f08b0 + 649f861 commit a9de4dc

14 files changed

+422
-326
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The following example creates and registers a conditional event named `plugin.magento.catalog.model.resource_model.product.save_low_stock_event`. Its parent is `plugin.magento.catalog.model.resource_model.product.save`. It defines rules that trigger when all of the conditions are true:
2+
3+
* The value of `qty` is less than `20`
4+
* The `category_id` is either `3`, `4`, or `5`
5+
* The product `name` contains `TV`
6+
* The `store_id` of product category is either `1` or `2`
7+
8+
These fields are present and declared in the parent event.

src/_includes/conditional-event.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
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.
2+
3+
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.
4+
5+
All conditional events contain the following information:
6+
7+
* A unique name for the conditional event.
8+
9+
* The name of the parent event. You must attach a conditional event to a specific registered event.
10+
11+
* One or more rules.
12+
13+
Each rule contains the following:
14+
15+
* A field that is defined in the parent event.
16+
17+
* An operator, which is represented as a comparison statement between the value supplied in the parent event's payload and the threshold value.
18+
19+
The operator must be one of the following:
20+
21+
| Operator | Description |
22+
| ----------- | ----------- |
23+
| `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. |
24+
| `lessThan` | Checks whether the payload value is less than a specified value. Applicable for integer and float data types. |
25+
| `equal` | Checks whether the payload value matches the specified value. For Boolean data types, use `1` to compare to `true` and `0` to compare to `false`. |
26+
| `regex` | A regular expression that checks for matches. The specified value must be compatible with the [regular expression match](https://www.php.net/manual/en/function.preg-match.php). |
27+
| `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. |
28+
29+
* 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 string `TV`, ignoring the case of the letters.

src/_includes/nested-event.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
When the payload contains an array of objects, use the following construction to register specific fields from that array:
2+
3+
```text
4+
<object_name>[].<field_name>
5+
```
6+
7+
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.
8+
9+
```json
10+
{
11+
"event": {
12+
"data": {
13+
"value": {
14+
"order_id": "8",
15+
"store_id": "1",
16+
"customer_id": null,
17+
"billing_address_id": "16",
18+
"shipping_address_id": "15",
19+
"global_currency_code": "USD",
20+
"base_currency_code": "USD",
21+
"store_currency_code": "USD",
22+
"order_currency_code": "USD",
23+
"store_to_base_rate": "0.0000",
24+
"store_to_order_rate": "0.0000",
25+
"base_to_global_rate": "1.0000",
26+
"base_to_order_rate": "1.0000",
27+
"discount_description": null,
28+
"items": [
29+
{
30+
"order_item_id": "8",
31+
"product_id": "22",
32+
"sku": "simple-product-2",
33+
"name": "Simple Product 2",
34+
"description": null,
35+
"price": 200,
36+
"base_price": "200.0000",
37+
"base_cost": null,
38+
"price_incl_tax": "200.0000",
39+
"base_price_incl_tax": "200.0000",
40+
"extension_attributes": {},
41+
"weee_tax_applied": "[]",
42+
"weee_tax_applied_amount": null,
43+
"weee_tax_applied_row_amount": 0,
44+
"base_weee_tax_applied_amount": null,
45+
"base_weee_tax_applied_row_amnt": null,
46+
"weee_tax_disposition": null,
47+
"base_weee_tax_disposition": null,
48+
"weee_tax_row_disposition": 0,
49+
"base_weee_tax_row_disposition": 0,
50+
"qty": "3.000000",
51+
"invoice": {},
52+
"parent_id": null,
53+
"store_id": "1",
54+
"row_total": 600,
55+
"base_row_total": 600,
56+
"row_total_incl_tax": 600,
57+
"base_row_total_incl_tax": 600,
58+
"tax_amount": 0,
59+
"base_tax_amount": 0,
60+
"discount_tax_compensation_amount": 0,
61+
"base_discount_tax_compensation_amount": 0,
62+
"base_weee_tax_applied_row_amount": 0
63+
},
64+
{
65+
"order_item_id": "9",
66+
"product_id": "21",
67+
"sku": "simple-product-1",
68+
"name": "Simple Product 1",
69+
"description": null,
70+
"price": 100,
71+
"base_price": "100.0000",
72+
"base_cost": null,
73+
"price_incl_tax": "100.0000",
74+
"base_price_incl_tax": "100.0000",
75+
"extension_attributes": {},
76+
"weee_tax_applied": "[]",
77+
"weee_tax_applied_amount": null,
78+
"weee_tax_applied_row_amount": 0,
79+
"base_weee_tax_applied_amount": null,
80+
"base_weee_tax_applied_row_amnt": null,
81+
"weee_tax_disposition": null,
82+
"base_weee_tax_disposition": null,
83+
"weee_tax_row_disposition": 0,
84+
"base_weee_tax_row_disposition": 0,
85+
"qty": "5.000000",
86+
"invoice": {},
87+
"parent_id": null,
88+
"store_id": "1",
89+
"row_total": 500,
90+
"base_row_total": 500,
91+
"row_total_incl_tax": 500,
92+
"base_row_total_incl_tax": 500,
93+
"tax_amount": 0,
94+
"base_tax_amount": 0,
95+
"discount_tax_compensation_amount": 0,
96+
"base_discount_tax_compensation_amount": 0,
97+
"base_weee_tax_applied_row_amount": 0
98+
}
99+
],
100+
"total_qty": 8,
101+
"subtotal": 1100,
102+
"base_subtotal": 1100,
103+
"subtotal_incl_tax": 1100,
104+
"base_subtotal_incl_tax": 1100,
105+
"grand_total": 1100,
106+
"base_grand_total": 1100,
107+
"discount_amount": 0,
108+
"base_discount_amount": 0,
109+
"tax_amount": 0,
110+
"base_tax_amount": 0,
111+
"discount_tax_compensation_amount": 0,
112+
"base_discount_tax_compensation_amount": 0,
113+
"base_cost": 0,
114+
"base_gift_cards_amount": 0,
115+
"gift_cards_amount": 0,
116+
"can_void_flag": false,
117+
"state": 2,
118+
"increment_id": "000000013",
119+
"entity_id": "13",
120+
"id": "13",
121+
"created_at": "2023-04-06 18:36:18",
122+
"updated_at": "2023-04-06 18:36:18"
123+
}
124+
}
125+
}
126+
}
127+
```
128+
129+
To register the top-level `order_id` field and the `sku` and `qty` of each product, define the subscription as follows:

src/_includes/sample-event.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
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:
2+
3+
```json
4+
{
5+
"event":{
6+
"data":{
7+
"value":{
8+
"_edit_mode":true,
9+
"store_id":"0",
10+
"entity_id":"3",
11+
"attribute_set_id":"4",
12+
"type_id":"simple",
13+
"sku":"test2",
14+
"has_options":false,
15+
"required_options":false,
16+
"created_at":"2022-07-28 14:13:40",
17+
"updated_at":"2022-09-06 20:37:25",
18+
"row_id":"3",
19+
"created_in":"1",
20+
"updated_in":"2147483647",
21+
"name":"test2",
22+
"meta_title":"test2",
23+
"meta_description":"test2 ",
24+
"page_layout":"product-full-width",
25+
"options_container":"container2",
26+
"url_key":"test2",
27+
"msrp_display_actual_price_type":"0",
28+
"gift_message_available":"2",
29+
"gift_wrapping_available":"2",
30+
"is_returnable":"2",
31+
"status":"1",
32+
"visibility":"4",
33+
"tax_class_id":"2",
34+
"price":"123.000000",
35+
"meta_keyword":"test2",
36+
"options":[
37+
38+
],
39+
"media_gallery":{
40+
"images":[
41+
42+
],
43+
"values":[
44+
45+
]
46+
},
47+
"tier_price":[
48+
49+
],
50+
"tier_price_changed":0,
51+
"quantity_and_stock_status":{
52+
"is_in_stock":"1",
53+
"qty":"333"
54+
},
55+
"category_ids":[
56+
"4"
57+
],
58+
"is_salable":1,
59+
"stock_data":{
60+
"item_id":"3",
61+
"product_id":"3",
62+
"stock_id":"1",
63+
"qty":"333",
64+
"min_qty":"0",
65+
"use_config_min_qty":"1",
66+
"is_qty_decimal":"0",
67+
"backorders":"0",
68+
"use_config_backorders":"1",
69+
"min_sale_qty":"1",
70+
"use_config_min_sale_qty":"1",
71+
"max_sale_qty":"10000",
72+
"use_config_max_sale_qty":"1",
73+
"is_in_stock":"1",
74+
"notify_stock_qty":"1",
75+
"use_config_notify_stock_qty":"1",
76+
"manage_stock":"1",
77+
"use_config_manage_stock":"1",
78+
"stock_status_changed_auto":"0",
79+
"use_config_qty_increments":"1",
80+
"qty_increments":"1",
81+
"use_config_enable_qty_inc":"1",
82+
"enable_qty_increments":"0",
83+
"is_decimal_divided":0,
84+
"website_id":"0",
85+
"deferred_stock_update":"0",
86+
"use_config_deferred_stock_update":"1",
87+
"type_id":"simple",
88+
"min_qty_allowed_in_shopping_cart":[
89+
90+
]
91+
},
92+
"use_config_gift_message_available":"1",
93+
"use_config_gift_wrapping_available":"1",
94+
"current_product_id":"3",
95+
"affect_product_custom_options":"1",
96+
"current_store_id":"0",
97+
"product_has_weight":"1",
98+
"is_new":"0",
99+
"website_ids":{
100+
"1":"1"
101+
},
102+
"url_key_create_redirect":"test2",
103+
"ignore_links_flag":false,
104+
"can_save_custom_options":true,
105+
"save_rewrites_history":true,
106+
"can_save_bundle_selections":false,
107+
"is_custom_option_changed":true,
108+
"parent_id":0,
109+
"special_from_date_is_formated":true,
110+
"custom_design_from_is_formated":true,
111+
"news_from_date_is_formated":true,
112+
"news_to_date_is_formated":true,
113+
"is_changed_categories":false,
114+
"is_changed_websites":false,
115+
"force_reindex_eav_required":true
116+
},
117+
"_metadata":{
118+
"commerceEdition":"Adobe Commerce",
119+
"commerceVersion":"2.4.6-beta5",
120+
"eventsClientVersion":"1.0.1",
121+
"storeId":"0",
122+
"websiteId":"1",
123+
"storeGroupId":"0"
124+
},
125+
"source":"demo.demo"
126+
}
127+
}
128+
}
129+
```
130+
131+
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`.

src/data/navigation/sections/events.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ module.exports = [
2020
path: "/events/configure-additional-event-providers.md",
2121
},
2222
{
23-
title: "Module development",
23+
title: "Create events from the Admin",
24+
path: "/events/create-events.md",
25+
},
26+
{
27+
title: "Create events",
2428
path: "/events/module-development.md",
2529
},
2630
{
2731
title: "Create conditional events",
2832
path: "/events/conditional-events.md",
2933
},
30-
{
31-
title: "Create events from the Admin",
32-
path: "/events/create-events.md",
33-
},
3434
{
3535
title: "Add custom fields",
3636
path: "/events/custom-event-fields.md"

src/pages/events/api.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -489,15 +489,15 @@ The `GET /V1/eventing/supportedList` endpoint returns the events supported in Ad
489489

490490
```json
491491
[
492-
{
493-
"name": "observer.customer_login"
494-
},
495-
{
496-
"name": "observer.customer_register_success"
497-
},
498-
{
499-
"name": "observer.customer_save_after"
500-
},
492+
{
493+
"name": "observer.customer_login"
494+
},
495+
{
496+
"name": "observer.customer_register_success"
497+
},
498+
{
499+
"name": "observer.customer_save_after"
500+
},
501501
...
502502
]
503503
```

src/pages/events/commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Event management commands
33
description: Provides details about the commands needed to set up Adobe I/O Events for Adobe Commerce.
4+
edition: paas
45
keywords:
56
- Events
67
- Extensibility

0 commit comments

Comments
 (0)