Skip to content

Commit 163027a

Browse files
authored
Add a chapter on the long filter for magento plugin (#65)
* Add a chapter on the long filter for magento plugin * Improve description, add some fancy things
1 parent 40b7746 commit 163027a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,37 @@ In this example we will search for customers that were updated after 1985 (`@dat
137137
# ...
138138
```
139139

140+
#### With long filter
141+
Filters are passed to the url.
142+
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.
144+
145+
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+
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.
152+
```yaml
153+
# ...
154+
order_filter_group:
155+
class: Kiboko\Component\Flow\Magento2\FilterGroup
156+
calls:
157+
- withLongFilter: [ '@order_filter' ]
158+
order_filter:
159+
class: Kiboko\Component\Flow\Magento2\FilterGroup
160+
calls:
161+
- withLongFilter: ['@order_increment_id', 0, 150]
162+
order_increment_id:
163+
class: Kiboko\Component\Flow\Magento2\Filter
164+
arguments:
165+
- 'increment_id'
166+
- 'in'
167+
- '000000526,4000000026,00000918,000001754,6000000123,4000000150,6000000185,000003798,6000000211,[..],5000000445'
168+
# ...
169+
```
170+
140171
### Building a lookup
141172
There is a lookup class for Categories, and one for product Attributes.
142173

0 commit comments

Comments
 (0)