0

I want to change to button actions in the Magento admin orders section, and after looking at a lot of posts on here I can not find an answer that fulfills my question:

Question: I want to be able to click the print invoice button on the order and have it automatically change to shipped status and when I add shipping to the order with a tracking number and click submit I would like that status to change to shipped.. and I was wondering how this could be done?

In summary: status changed to shipped - when invoice is printed status changed to complete - when order is shipped

I assume I would start in editing this section: app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php

rrrcode
  • 107
  • 3
  • 10

1 Answers1

0

To change the status of an order the instruction is :

 $order->setState('your state', true); 

Ex. :

$order->setState('complete', true);

To have what you want you should edit the controller called when printing the invoice or creating the shipment. It's :

/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php in the printAction() method just after the line :

$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($invoice));

For the printing of invoice and

/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php in the saveAction() method just after the line :

 $shipment->register();

But editing Controller is the most simple but the worst solution. If you know well Magento and php you could do this through Model or through events.

Best Regards,

dagfr
  • 2,349
  • 1
  • 19
  • 22
  • I tried the following: 1) I went to '/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php' and located the line of 'printAction()' method and just after the line below: '$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($invoice));' I put this: '$order->setState('processing', true);' When I did that I got this warning when trying to print an invoice from the order screen Fatal error: Call to a member function setState() on a non-object in domain.com/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php on line 120 – rrrcode Dec 19 '12 at 13:31