I wrote a module that adds a mass action for creating invoices and shipments from the invoice. This gets done by calling the URL ./sales_order/finishorder (calls the finish_order function.
After finishing creating the invoices and shipments I wanted to redirect to pdfinvoices to directly print the PDFs for the orders. I tried this using




but neither will work: The first one just leads back to the order grid, the second one displays a blank page.
I think the second one is correct but the required POST parameters are missing. Is there a way to redirect them to sales_order/pdfinvoices?

  • Both variants seems to be the same – alex_b Oct 28 '14 at 21:01
  • Thanks, typo. They are basically the same. Just not sure which path is correct – Bernie Oct 28 '14 at 21:03

The first line in pdfinvoices is:

$orderIds = $this->getRequest()->getPost('order_ids');

Thus it is expecting an array list of order ids to work on.

Make sure your mass action variable is called order_ids. If you then forward to the pdfinvoice action, it will use the same order ids you just worked on.

If, for some reason you need to eliminate any ids from the list, (could not process shipping as an example), build a new array of allowed order ids.

Then just before you _forward, inject the order ids you want to process into the post variable.

| improve this answer | |

As I see both methods are in the same controller, so you can do it like this in the end of finishorder method:

// set post
| improve this answer | |
  • Didn't work. I now get forwarded to: index.php/admin/admin/sales_order/finishorder/key/cd51c5eacefec860ea70108762ff8ec6/form_key/tgkIpGxDc1jPTCBY/massaction_prepare_key/order_ids/ Which seems to be the right URL but with the wrong parameters, I guess? I am not sure if the parameters are the problem but it is my best guess after some research. – Bernie Oct 28 '14 at 21:23
  • What parameters should be passed to sales_order/pdfinvoices? only order_ids I guess? – alex_b Oct 28 '14 at 21:27
  • Yes, exactly. The order_ids that I get from the order grid when I call it as a mass action. I did however not manage to find out in what way the parameters are sent. If I try to convert the post parameters to get parameters using a plugin it does not find any. – Bernie Oct 28 '14 at 21:28
  • 1
    You can just use _forward('pdfinvoices') if the actions are in the same controller. There is no need to pass on the request variables. _forward can also forward to other controller actions. See parent class for syntax. _forward will be preffered over _redirect in a lot of instances, as it does not result in a new page request. – ProxiBlue Oct 28 '14 at 23:40
  • Thank you ProxiBlue and alex_b, I was not aware of "_forward". Works like a charm now! – Bernie Oct 29 '14 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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