cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a custom module to send order details to external supplier API via XML or JSON

Creating a custom module to send order details to external supplier API via XML or JSON

Hi,

 

I'm trying to write a custom module for Magento that when certain items are ordered and payment has been made, posts to our clothing supplier's site with details of the ordered item, delivery address and other data in either XML or JSON format.

 

Whilst I've been a web developer for some years, I haven't worked with the Magento system much before and was wondering if anyone could point me in the right direction?

 

I think I've found a hook (sales_order_invoice_save_after) that could do the trick but not too sure it's the right one or how to begin putting the code together!

 

Thanks in advance

3 REPLIES 3

Re: Creating a custom module to send order details to external supplier API via XML or JSON

To anyone else looking for an answer to this question, I have found the following tutorial which seems to get me 80% of the way there, the rest is just PHP!

 

http://www.solvingmagento.com/events-and-observers-a-magento-tutorial/

 

 

Re: Creating a custom module to send order details to external supplier API via XML or JSON

Hello,

 

Its better to use events and handlers instead of overrriding some functionality by creating module for same.

 

Thanks

Re: Creating a custom module to send order details to external supplier API via XML or JSON

Adding my two cents - remember that if your order details are sent before the response is written to the browser you will make that PHP process slower. Your code will be on the critical path on delivering a page to the browser.

 

It may be OK, or it may not be. It depends how much time your code adds and at which point in the sales process. You wrote about order details, so having a quick response may not be critical, as the order has already been placed and the visitor will just wait a bit longer for the final "thank you" page.

 

Otherwise: yes, it's fine to use events and observers.

Alternatively, you could create a Cron job which pushes all orders or integrate from the other end using the Magento API to pull all required order details.

 

Best,

Radek

Cart Defender - slash cart abandonment and drive sales with unlimited intelligent conversion popups. Forget A/B tests because Cart Defender optimizes itself automatically. Web Summit 2016