I'm am improving Magento plugin that my friend wrote and I need to add a logic where I check each order and if the total sum is less than x then get this order details like total amount, name, address, phone number etc. And with these order details create XML and send out this XML to an external provider. At the same time send out to the customer the invoice and add to order comments in admin panel with some text like order placed from external provider. And do this only if the order total sum is less or equals than x.

I haven't done plugin from scratch myself, but the current plugin is made by a friend who due to some reasons can't continue and help me with that then I need to make it myself. What my current knowledge is that I know how to make additional tabs and fields in Admin -> Configuration. So there I currently have set up the field enable/disable the plugin and a text field make order from an external provider if the sum is less than x.

What I'm unfamiliar is how to observe all the going through orders? And get out the order total amount from that as well as order details I stated above. Also, I need to change the order status to processing and add a comment with my text. I guess the XML creation and sending out to the external provider is standard PHP task (use Varien/Zend in Magento) and is not related to Magento architecture.

Any tutorials for that, examples or your hints would be appreciated. I don't really want to dive deep into Magento architecture and read whole books, but just need to get this done. I tried to google about that but didn't get any good examples/tutorials maybe cause I don't write the problem in better Magento architecture/terms.

1 Answer 1


I guess in this case you would want to observe the invoice to create an event to make sure an order is paid. The event is called sales_order_invoice_save_after.

This Magento wiki page tells you how to implement a simple observer from a custom extension. In your case the $observer variable will most likely contain the order by calling ->getOrder(). I suggest printing the getData() method of that order to see what data you can get from there.

On how to build a custom extension please check this link. I find that it outlines how to go about it pretty well.

As the question you've posted is very broad I suggest starting on building your extension and posting more direct questions if you need help later on.

  • Hi, Thanks for the input, I will take a look now and try to accomplish that.
    – Skyzer
    Commented Oct 2, 2013 at 12:23
  • I did it, thanks to the 2 tutorials that i found that did exactly same thing that i wanted! And thanks to you also Sander! solvingmagento.com/… solvingmagento.com/events-and-observers-a-magento-tutorial
    – Skyzer
    Commented Oct 5, 2013 at 17:51
  • good to hear, if you have any tips for future googlers please make sure to add them in an answer or update your question :) Commented Oct 5, 2013 at 19:30

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.