Child pages
  • ERP Integration - Orders
Skip to end of metadata
Go to start of metadata

The Magento ERP integration supports both importing new Orders to the ERP system and also to update Order statuses back from ERP to Magento. This is achieved by letting the ERP-supplier call for (a list of) New Orders from Magento using a JSON request, and afterwards fetching new Orders into the ERP system one by one.

Here you will find the necessary details on how to Export orders (from Magento) and also how to Update order statuses back to Magento.

There are three requests that should be implemented:

Get list of new Orders from Magento

The request will give a list of all new orders from Magento that are ready to be imported into the ERP-system (i.e. that are not yet marked as exported, which our Magento module will take care of).

The request is a simple and easy JSON format.

URL to call: http://yourstore.com/navimage/order/list/

Example of response

 

{"orders":["17289","17290","17291","17292","17293","17294","17295","17296","17297","17298","17299","17300","17301"]}

 

Get specific Order from Magento

There will be created one single XML (file/response) per Magento Order.

URL to call: http://yourstore.com/navimage/order/export/id/[id]

XML format of the Order in the response

 

<?xml version="1.0" encoding="UTF-8"?>
<order>
  <header>
    <order_id>30</order_id>
    <increment_id>100000026</increment_id>
    <customer_id>8</customer_id>
    <shipping_amount>21.6000</shipping_amount>
    <shipping_description>Bring - Brev (A-Prioritert)</shipping_description>
    <subtotal>52.8000</subtotal>
    <tax_amount>20.6000</tax_amount>
    <grand_total>103.0000</grand_total>
    <discount_amount>0.0000</discount_amount>
    <shipping_discount_amount>0.0000</shipping_discount_amount>
    <total_item_count>1</total_item_count>
    <weight>234.0000</weight>
    <order_currency_code>NOK</order_currency_code>
    <coupon_code/>
    <created_at>2012-08-22 10:41:15</created_at>
    <shipping_carrier>bring</shipping_carrier>
    <shipping_method>fraktguiden_A-POST</shipping_method>
    <store_id>1</store_id>
    <paymentmethod>groupinvoice</paymentmethod>
    <customerType>person</customerType>
    <pbb_customerno/>
    <customer_comment/>
    <transaction_id/>
    <nets_giftcardamount>1.00</nets_giftcardamount>
    <invoicefee>8.0000</invoicefee>
    <invoicefee_tax>2.0000</invoicefee_tax>
  </header>
  <shipping_address>
    <firstname>Kjell</firstname>
    <lastname>Hansen</lastname>
    <company/>
    <street>Andregata 2</street>
    <region>Rogaland</region>
    <postcode>4016</postcode>
    <city>Stavanger</city>
    <country_id>NO</country_id>
    <email>kjell@hansen.net</email>
    <telephone>12345678</telephone>
    <fax/>
  </shipping_address>
  <billing_address>
    <firstname>Kjell</firstname>
    <lastname>Hansen</lastname>
    <company/>
    <street>Andregata 2</street>
    <region>Rogaland</region>
    <postcode>4016</postcode>
    <city>Stavanger</city>
    <country_id>NO</country_id>
    <email>kjell@hansen.net</email>
    <telephone>12345678</telephone>
    <fax/>
  </billing_address>
  <lines>
    <line>
      <line_no>1</line_no>
      <sku>ak-potet-14</sku>
      <name>Potetskreller med motor</name>
      <description/>
      <qty_ordered>3.0000</qty_ordered>
      <qty_backordered/>
      <price>17.6000</price>
      <original_price>22.0000</original_price>
      <weight>78.0000</weight>
      <tax_percent>25.0000</tax_percent>
      <tax_amount>13.2000</tax_amount>
      <discount_percent>0.0000</discount_percent>
      <discount_amount>0.0000</discount_amount>
      <row_total>52.8000</row_total>
      <row_weight>234.0000</row_weight>
    </line>
    <line>
      <line_no>2</line_no>
      <sku>invoicefee</sku>
      <name>Fakturagebyr</name>
      <description/>
      <qty_ordered>1</qty_ordered>
      <qty_backordered>0</qty_backordered>
      <price>8</price>
      <original_price>8</original_price>
      <weight>0</weight>
      <tax_percent>25.00</tax_percent>
      <tax_amount>2</tax_amount>
      <discount_percent/>
      <discount_amount/>
      <row_total>8</row_total>
      <row_weight>0</row_weight>
    </line>
  </lines>
</order>

 

Note on <line_no> field

Icon

This field is unique for the whole site, so the <line_no>1</line_no> will appear only once.

However, there are some special line number that might appear several times.

Line no
Description
0Indicates that this is an extra fee of some sort, can be invoice fee, handling fee, or other extra cost.
-1Indicates that this line is a custom option that refers to the previous order line.

 

Order update from ERP to Magento

The integration supports sending back Order updates from the ERP system to Magento, so that the Magento Order can be set to Completed once ERP has packed and shipped the items.

When Magento gets an order update from the ERP system, it will create a standard Magento Shipment and also capture the payment for the lines supplied in the update. Based on the "Order_status", it will either cancel any undelivered items on the Order and finish it, or keep the Order open for later deliveries (part deliveries).

Each Order Update POST must include only one Order.

Tracking_number is optional.

URL to POST to: http://yourstore.com/navimage/order/update/

XML format of the Order Update file

 

<?xml version="1.0" encoding="UTF-8"?>
<Order_confirmation>
  <Header>
    <Order_number>100000249</Order_number>
    <Order_status>Completely Shipped</Order_status>
    <Tracking_number>976362718192</Tracking_number>
  </Header>
  <Lines>
   <Line>
   <Sku>10-002-2</Sku>
   <Qty>4</Qty>
   </Line>
  </Lines>
</Order_confirmation>

 

How to handle order update when the item number (SKU) has been changed

There are two ways to handle this, both supporting capture of the original item.

Alternative 1 (recommended)

Include the unique <Line_no> per row which was sent in the original Order Import from Magento to the ERP system.

Alternative 2

Send the original SKU in a new <Sku2></Sku2> field (in the Order Update file), and include the NEW SKU (replacement SKU) in the <Sku></Sku> field.

The "Order_status" can have one of the following statuses

Order status
Description
Partially ShippedMagento will create a shipment for the items specified. If there are remaining items in the order, they will be kept for later delivery. If all items are delivered the order will be closed.
Completely ShippedMagento will create a shipment for the items specified. If there are remaining items in the order, they will be cancelled and the order will be closed.

The response from Order Updates can be either XML or JSON

Code
Description
OKEverything went OK. The message tag will contain "Order processed"
ErrorSomething went wrong. The message tag will contain a message about what went wrong.

XML example

 

<?xml version="1.0"?>
<response>
    <code>OK</code>
    <message>Order processed</message>
</response>

 

XML Error example

 

<?xml version="1.0"?>
<response>
    <code>Error</code>
    <message>InvoiceAPI: Invalid qty to invoice item "Kult produkt" (100000249)</message>
</response>

 

JSON example

 

{"code":"OK","message":"Order processed"}
  • No labels