Hi, this may have been posted in the wrong category - its my first post here.
I'm in the process of creating a Store Finder facility which reads a list of stores within Umbraco and plots them on a map.
All is working fine. However, I'm having to manually add each store. As the list of stores is approaching 600+, this is going to put me into an early grave!
Is there a simple way of importing a CSV list of all stores and have the columns match up to the corresponding properties in my DocType?
My structure is as follows:
StoresList (Doctype: 'StoresList')
Store 1 (DocType: 'StoreDetails')
Name
Address
Postcode
Latitude
Longitude
Store 2
...
So for each row in the CSV I want to create a new Store under StoresList
Anyways, rather than writing to the database directly, you can use Umbraco's content service. I'm assuming you only have do to this import once, so you can simply use one of your views - this could look like:
@using Umbraco.Core.Services
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "Master.cshtml";
}
@{
// ID of the arent (eg. the ID of your "StoreList")
int idOfParent = 1234;
// Get a reference to the content service
IContentService cs = UmbracoContext.Current.Application.Services.ContentService;
// Create a new content item ("Store 1" will be the name)
IContent store = cs.CreateContent("Store 1", idOfParent, "StoreDetails");
// Update any properties
store.SetValue("address", "Somehwere");
// Save and publish the content item (store)
cs.SaveAndPublishWithStatus(store);
}
This example only adds a single store, but it gives an idea on how to add content. By using the content service, everything is added correctly, an the content item (store) will also automatically be published.
CSV Import of a list of retail stores
Hi, this may have been posted in the wrong category - its my first post here.
I'm in the process of creating a Store Finder facility which reads a list of stores within Umbraco and plots them on a map.
All is working fine. However, I'm having to manually add each store. As the list of stores is approaching 600+, this is going to put me into an early grave!
Is there a simple way of importing a CSV list of all stores and have the columns match up to the corresponding properties in my DocType?
My structure is as follows:
So for each row in the CSV I want to create a new Store under StoresList
I have SQL access.
Any help would be greatly appreciated.
Hi Ajay and welcome to Our,
Do you have an example of the CSV file?
Anyways, rather than writing to the database directly, you can use Umbraco's content service. I'm assuming you only have do to this import once, so you can simply use one of your views - this could look like:
This example only adds a single store, but it gives an idea on how to add content. By using the content service, everything is added correctly, an the content item (store) will also automatically be published.
Hi,
Have you found CMSImport? Really easy to import csv into Umbraco. If you use two files you can even use the free version
http://soetemansoftware.nl/cmsimport
Hope you can use this.
Best,
Richard
is working on a reply...