Skip to content

Commit cdfe8ba

Browse files
committed
Edit the chapter on magento to include the refacto of filters, fix the section on the long filter too
1 parent 02352cd commit cdfe8ba

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

content/connectivity/magento-2/_index.en.md

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ The package includes the following extractor classes: `CustomerExtractor`, `Invo
3535

3636
Extractor classes take 4 arguments:
3737

38-
| name | description | type | default value |
39-
|---------------|--------------------------------------------------------------------------------------------------|--------------------------|---------------|
40-
| logger | the service that will log exceptions | \Psr\Log\LoggerInterface | |
41-
| client | client to choose depending on the Magento version. Available clients are: V2_1, V2_2, V2_3, V2_4 | Client | |
42-
| page size | (Optional) maximum amount of entities to retrieve in a single payload | int | 100 |
43-
| filter groups | (Optional) groups of filters to use when searching for entities | array | [] |
38+
| name | description | type | default value |
39+
|------------------|----------------------------------------------------------------------------------------------------|--------------------------|---------------|
40+
| logger | the service that will log exceptions | \Psr\Log\LoggerInterface | |
41+
| client | client to choose depending on the Magento version. Available clients are: V2_1, V2_2, V2_3, V2_4 | Client | |
42+
| query parameters | query parameters send to the api who contains groups of filters to use when searching for entities | array | [] |
43+
| page size | (Optional) maximum amount of entities to retrieve in a single payload | int | 100 |
4444

4545
```yaml
4646
custom:
@@ -52,8 +52,8 @@ custom:
5252
arguments:
5353
- '@Monolog\Logger' # Logger
5454
- '@Kiboko\Magento\V2_1\Client' # Client
55+
- [] # QueryParameters, contains filters
5556
- 500 # Page size
56-
- [] # Filter groups
5757

5858
Kiboko\Magento\V2_1\Client:
5959
factory:
@@ -89,7 +89,7 @@ custom:
8989
- 300 # Log level. 300 for Warning, 200 for Info...
9090
```
9191
92-
#### With filters
92+
#### With ScalarFilters
9393
Filters and filter groups can be specified.
9494
Filters in a group are chained with `OR`. Groups are chained with `AND`.
9595

@@ -101,18 +101,22 @@ In this example we will search for customers that were updated after 1985 (`@dat
101101
arguments:
102102
- '@Monolog\Logger'
103103
- '@Kiboko\Magento\V2_1\Client'
104+
- '@query_parameters'
104105
- 500
105-
- [ '@date_filter_group', '@id_filter_group' ]
106-
# updated_at >= 1985-10-26 11:25:00 AND (entity_id = 17 OR entity_id = 46)
107106
108107
# ...
109108
109+
query_parameters:
110+
class: Kiboko\Component\Flow\Magento2\QueryParameters
111+
calls:
112+
- withGroups: [ '@id_filter_group', '@date_filter_group' ]
113+
# updated_at >= 1985-10-26 11:25:00 AND (entity_id = 17 OR entity_id = 46)
110114
date_filter_group:
111115
class: Kiboko\Component\Flow\Magento2\FilterGroup
112116
calls:
113117
- withFilter: [ '@last_execution' ]
114118
last_execution:
115-
class: Kiboko\Component\Flow\Magento2\Filter
119+
class: Kiboko\Component\Flow\Magento2\Filter\ScalarFilter
116120
arguments:
117121
- 'updated_at'
118122
- 'gteq'
@@ -123,48 +127,49 @@ In this example we will search for customers that were updated after 1985 (`@dat
123127
calls:
124128
- withFilter: [ '@id_to_check', '@other_id' ]
125129
id_to_check:
126-
class: Kiboko\Component\Flow\Magento2\Filter
130+
class: Kiboko\Component\Flow\Magento2\Filter\ScalarFilter
127131
arguments:
128132
- 'entity_id'
129133
- 'eq'
130134
- '17'
131135
other_id:
132-
class: Kiboko\Component\Flow\Magento2\Filter
136+
class: Kiboko\Component\Flow\Magento2\Filter\ScalarFilter
133137
arguments:
134138
- 'entity_id'
135139
- 'eq'
136140
- '46'
137141
# ...
138142
```
139143

140-
#### With long filter
144+
#### With ArrayFilter
141145
Filters are passed to the url.
142146
But the most popular web browsers will not work with URLs over 2000 characters, and would return a 414 (Request-URI Too Long).
143-
You can use the method `withLongFilter` to avoid this limitation and batch your request in multiple smaller requests.
147+
You can use the class `ArrayFilter` to avoid this limitation and batch your request in multiple smaller requests.
144148

145149
In this example we will search for specific orders with a lot of elements in the request's filter.
146-
We have 214 increment_id, and we use a `withLongFilter` with parameters:
147-
- `@order_increment_id` references our order's filter.
148-
- `offset`, starts the request at the chosen index, by default we have 0.
149-
- `length`, defines a batch length, by default we have 200.
150+
We have 214 increment_id, and we use the `ArrayFilter` with parameters:
151+
- `increment_id` field targeted by the filter.
152+
- `in` operator to the filter, you need the 'in' operator to use the ArrayFilter.
153+
- `000000526,4000000026,00000918,000001754,6000000123,4000000150,6000000185,000003798,6000000211,[..],5000000445` defines the target values.
154+
- `150` defines the lenght of your smaller request (by default set to 200).
150155

151-
Here we have set an offset to 0 and a length to 150, it means we are starting the request from the first element and make multiple requests with 150 items max.
152156
```yaml
153157
# ...
154-
order_filter_group:
155-
class: Kiboko\Component\Flow\Magento2\FilterGroup
158+
query_parameters:
159+
class: Kiboko\Component\Flow\Magento2\QueryParameters
156160
calls:
157-
- withLongFilter: [ '@order_filter' ]
161+
- withGroup: [ '@order_filter' ]
158162
order_filter:
159163
class: Kiboko\Component\Flow\Magento2\FilterGroup
160164
calls:
161-
- withLongFilter: ['@order_increment_id', 0, 150]
165+
- withFilter: ['@order_increment_id']
162166
order_increment_id:
163-
class: Kiboko\Component\Flow\Magento2\Filter
167+
class: Kiboko\Component\Flow\Magento2\Filter\ArrayFilter
164168
arguments:
165169
- 'increment_id'
166170
- 'in'
167171
- '000000526,4000000026,00000918,000001754,6000000123,4000000150,6000000185,000003798,6000000211,[..],5000000445'
172+
- 150
168173
# ...
169174
```
170175

0 commit comments

Comments
 (0)