0

I will create a redirect with a very big custom variable in the Magento 2 backend.

Now I use this method:

$resultRedirect->setPath('custom/url/index',array('_query'=>array('very_big_array'=>$arr);

When I try this, my server says: This URL is too long.

How can I pass a very big variable within my redirect? Maybe the only way is: set a session? But if yes, how can I do this? Do I need this Session manager?

\Magento\Backend\Model\Session $backendSession

Thanks for your reply.

2
  • from where to where to you want to pass the varibale? Could you explain the use case? Maybe the session is indeed the right place for it Commented May 17, 2017 at 20:10
  • I have created a custom order Mass Action. When a user selects a few orders, this Mass Action function redirects the selected orders to my custom Magento 2 admin module. And when a user selects 200 orders, it's a very big array for a url... Commented May 17, 2017 at 20:13

1 Answer 1

1

ok, since this query can get uncontrollably long, it definetly should not be a url param.

One way would be to store the data in the backend session (as you already described).

Another way would be to use the DataPersistor provided by the Magento2 Framework:

Magento\Framework\App\Request\DataPersistorInterface

this seems to be a new method to store data between requests in magento2, like used here in the product/save action: https://github.com/magento/magento2/blob/develop/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php#L153

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.