I am working on a custom module. I need order data in my own controller. I want users to use the checkboxes to select orders so i can use the order id's/data in my controller. How do I do this?
What I have done so far:
- Make module
- Add massaction with custom url to the sales order grid
- Setup routing for my custom url
- Created controller so my custom url works
I don't know how I can get the selected order id's in my controller. I asked this: Magento 2: How to get Post data in backend/adminhtml? But the POST Data doesn't contain the order id's.
How can I proceed? What is the next step? And how do I achieve that?
Best Answer
\Magento\Ui\Component\MassAction\Filter::getCollection
is responsible for adding filter criteria to your collection and you can iterate through it to do some mass action. It will obtain \Magento\Ui\Component\MassAction\Filter::(SELECTED|EXCLUDED)_PARAM param from request and use it as filter for collection. See\Magento\Catalog\Controller\Adminhtml\Product\MassDelete
for example.