Channel Advisor Order Import
Overview
Core dna has the ability to import orders from Channel Advisor on a nightly basis. This import is controlled by a switch in the orders configuration. A optional config JSON file handles the mapping of all fields From Channel Advisor to Core dna, if you do not provide this then the default engine config will be used. Logs for each run are saved in the reports section.
This script is run on the Core dna backend and must be enabled for your site.
Note 1 Core dna fetches orders using the exported flag, this flag is not visible on the CA interface and it is per integration. Once a order is imported into Core dna it is marked as exported via an API request. If you change the keys then Channel Advisor will treat it as a brand new integration and return every order again. Read more:
Note 2 On first run, Core dna will create a "Start Date" filter, this means we will only ever fetch orders from the first run date. This start date is never updated as the export functionality will ensure we only get new orders. This date filter is used so we do not sync all the older orders that may reside on the Channel Advisor system.
Setup
Get Channel Advisor Developer Credentials.
In order to connect to Channel Advisor we need the developer credentials from Channel Advisor, follow the steps detailed below:
(This step only needs to be taken if this is the first time connecting to CA for this site)
Once you have set this up, In Core dna navigate to Transactions → Inventory and then click Configure → Inventory Plugins.
Select Channel Advisor from the Provider drop down and enter the required fields. Then click on the Channel Advisor logo and you will be taken to their OAuth site to grant permission. Once you accept you will be returned to Core dna and the Channel Advisor Oauth configuration is now complete.
Config File
Core dna allows each site to load a custom JSON config file to easily control the mapping of each field. If no config is provided then the default engine config will be used. The file must be located here:
sitedir/modules/prodcatalogueorder/templates/ca/orders.json |
and the contents must be formatted as follows
{ "order" : { "name" : "ShippingFirstName ShippingLastName" , "email" : "BuyerEmailAddress" , "payment_method" : "PaymentMethod" , "order_custom1" : "SiteOrderID" , "order_custom2" : "SiteName" , "order_custom3" : "'Imported from Channel Advisor'" , "date_purchased" : "CreatedDateUtc" , "order_total" : "TotalPrice" , "order_tax" : "TotalTaxPrice" , "delivery_price" : "TotalShippingPrice" , "del_method" : "RequestedShippingClass" , "order_date_finished" : "PaymentDateUtc" , "del_name" : "ShippingFirstName ShippingLastName" , "del_unit" : "" , "del_email" : "BuyerEmailAddress" , "del_phone" : "ShippingDaytimePhone" , "del_company" : "ShippingCompanyName" , "del_address" : "ShippingAddressLine1" , "del_suburb" : "ShippingAddressLine2" , "del_city" : "ShippingCity" , "del_postcode" : "ShippingPostalCode" , "del_state" : "ShippingStateOrProvinceName" , "del_countryid" : "ShippingCountry" , "billname" : "BillingFirstName BillingLastName" , "billemail" : "BuyerEmailAddress" , "billphone" : "BillingDaytimePhone" , "billcompany" : "BillingCompanyName" , "billunit" : "" , "billaddress" : "BillingAddressLine1" , "billsuburb" : "BillingAddressLine2" , "billcity" : "BillingCity" , "billpostcode" : "BillingPostalCode" , "billstate" : "BillingStateOrProvinceName" , "billcountryid" : "BillingCountry" }, "item" : { "bundle_id" : "" , "bundle_name" : "" , "bundle_quantity" : "" , "products_id" : "" , "category_id" : "" , "variant_id" : "" , "products_code" : "Sku" , "products_name" : "Title" , "list_price" : "" , "products_price" : "UnitPrice" , "discount" : "" , "final_price" : "UnitPrice" , "products_tax" : "TaxPrice" , "products_tax_price" : "TaxPrice" , "price_portion_percent" : "" , "product_type" : "" , "products_quantity" : "Quantity" , "tax_code" : "" , "parent_id" : "" , "warehouse_id" : "" } } |
On the left is the Core dna key, on the right is the Channel Advisor key. You should modify the Channel Advisor keys. You can see the Channel Advisor data returned in the report logs, this will help you see what data is coming in and how to map accordingly.
The config also allows some extra functionality:
- If a single value is given, Coredna will assume this is a value returned from Channel Advisor, eg: "UnitPrice". If no such data is returned then nothing will be saved into that field.
- It is possible to handle multiple values in the same mapping, eg: "FirstName SecondName". In this case the entire string will be used with the keys being replaced, this means any spacing or custom characters will also be included. eg: "FirstName abc123 LastName" will become "Tim abc123 Tam".
You can provide a hard-coded string which does not rely on Channel Advisor data by surrounding the value in single quotes, for example:
"order_custom3": "'Imported from Channel Advisor'"
If you do not provide the single quotes Core dna will treat it as a multiple Channel Advisor key mapping.
Enable Order Import
Navigate to Transactions → Commerce → Configure → Manage Configuration. Near the bottom of this screen you will see a section called Channel Advisor Order Import. Enable the switch the orders will be imported on next run.
Reporting
Under Cog Wheel → Reporting, you will see a log file "orders_channel_advisor_" this will show the output for that import session. This logging area show a lot of information so please check this for any issues.