0
votes

I need to tweak magento admin so after a new invoice is created at a link like this:

admin/sales_order_invoice/new/order_id/550/

to redirect to

/admin/sales_order_invoice/view/invoice_id/384/order_id/550/

Right now, after an order is created magento redirects to admin/sales_order/view/order_id/542/

L.E.

Found out that redirect url is set in saveAction() from app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php

Does anyone know a way to retrieve created invoiced inside that function?

1
and why what is your purpose for that?Anton S
On the shop the invoice is printed immediately after generated. So the purpose is to eliminate two additional page loading in order to reach the created invoice.Ovidiu

1 Answers

2
votes

I know this is an old question and the Mage_Adminhtml_Sales_Order_InvoiceController class may have changed since the question was asked, but I thought it may help someone.


The invoice object is already available in the saveAction function and is initialized in the _initInvoice function. To access the invoice id you just need to use $invoice->getId().

To update the URL you just need to change this:

$this->_redirect('*/sales_order/view', array('order_id' => $orderId));

to this:

$this->_redirect('*/sales_order_invoice/view', array('invoice_id' => $invoice->getId(), 'order_id' => $orderId));