Skip to content

Add a chapter on the long filter for magento plugin #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions content/connectivity/magento-2/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,37 @@ In this example we will search for customers that were updated after 1985 (`@dat
# ...
```

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

In this example we will search for specific orders with a lot of elements in the request's filter.
We have 214 increment_id, and we use a `withLongFilter` with parameters:
- `@order_increment_id` references our order's filter.
- `offset`, starts the request at the chosen index, by default we have 0.
- `length`, defines a batch length, by default we have 200.

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.
```yaml
# ...
order_filter_group:
class: Kiboko\Component\Flow\Magento2\FilterGroup
calls:
- withLongFilter: [ '@order_filter' ]
order_filter:
class: Kiboko\Component\Flow\Magento2\FilterGroup
calls:
- withLongFilter: ['@order_increment_id', 0, 150]
order_increment_id:
class: Kiboko\Component\Flow\Magento2\Filter
arguments:
- 'increment_id'
- 'in'
- '000000526,4000000026,00000918,000001754,6000000123,4000000150,6000000185,000003798,6000000211,[..],5000000445'
# ...
```

### Building a lookup
There is a lookup class for Categories, and one for product Attributes.

Expand Down