I'd like to use the Magento's print feature in my module to have the invoice pdf of a programmatically created order. For that I'd like to get the url that Magento back end uses to print the invoice. eg : http://localhost/magento1/index.php/admin/sales_order_invoice/print/invoice_id/104/key/eaf550ef39cc92e93b562994019fde14/ enter image description here

My question is how can I get that key to build the url that retrieves the invoice pdf ?

1 Answer 1


just write below code


and it will autometically add key

  • This generate the following link : http://localhost/magento1/index.php/sales_order_invoice/print/invoice_id/key/1c762f48f0b4a305a038d599b84bda83/. This does not add the invoice_id (104 in our example). I don't know why it does not add the invoice_id ... Dec 26, 2016 at 11:25
  • Is it a bug in Magento ... ? Dec 26, 2016 at 11:43
  • 2
    @androniennn Magento always generate unique key everytime, so dont worry Dec 26, 2016 at 12:03
  • 2
    @androniennn, I have written same kind of code abt 1 year ago so that's why I know , and from my study I know that There is always this kind of function available for getting keys whether its form_key or url_key Dec 26, 2016 at 12:08
  • 1
    @androniennn I am not sure but you can try this Mage::helper("sales")->getUrl("adminhtml/sales_order_invoice/print/invoice_id/104/"); Dec 27, 2016 at 5:07

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.