Import Shipping addresses from Json file in Commerce

Vote:
 

Hi Team!

I have a requirement to Import all addresses from accountAddress.json which will looks like below.

{
"id": "100482",
"addresses": [
{
"id": "01",
"type": "SHIP",
"street": "Army Six Q Store, RNZAF Base Hobsonville, Hudson Bay Rd, 1250 H/ville",
"address": "Army Six Q Store, RNZAF Base Hobsonville, Hudson Bay Rd, 1250 H/ville, Auckland"
},
{
"id": "02",
"type": "SHIP",
"street": "NZ Defence Force - Auckland Army Centre, 204-234 Great North Road, Grey Lynn",
"address": "NZ Defence Force - Auckland Army Centre, 204-234 Great North Road, Grey Lynn, Auckland"
}
]
},
{
"id": "100965",
"addresses": [
{
"id": "01",
"type": "SHIP",
"street": "Alltex Plastering, 66 School Road, R.D.4 Tomarata",
"address": "Alltex Plastering, 66 School Road, R.D.4 Tomarata, Wellsford"
}
]
},

 Is there any inbult feature to do this or we need to right any Job to accomplish this.

Here "id" represents the Organization Code.

Please help me on this.

Thank You

#206177
Aug 06, 2019 12:58
Vote:
 

We don't have any built in service to do that and you need to create custom one.

And, in Episerver Commerce, we only have import/export feature for catalog items.

#206178
Edited, Aug 06, 2019 15:51
Pratap - Aug 07, 2019 6:54
Thank you Praful
Vote:
 

I'm unable to create any custom method or Job to import the data from json.

Any one help to create the custom Job to import the addresses from Json file into every Organization.

That would be helpful for me.

Thank you!

#206192
Edited, Aug 07, 2019 6:57
Vote:
 

You would have to deserialize the JSON, and then create an OrderAddress based on the data, then add that to an order as ShippingAddress

public static OrderAddress CreateOrderAddress(string name = "fake address")
{
return new OrderAddress()
{
Name = name,
ModifierId = PrincipalInfo.CurrentPrincipal.GetContactId().ToString(),
Modified = DateTime.Now.ToUniversalTime(),
City = "Chicago",
FirstName = "foo",
LastName = "bar",
Email = "foo@bar",
CountryCode = "USA",
State = "Illinois",
PostalCode = "60181"
};
}

#206203
Aug 07, 2019 9:56
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.