Does anyone have any experience in importing values into archetype using CMSImport.
I need to import 3 values in separate columns of an excel file into an archetype, making each value a separate item. Has anyone ever imported into archetype that could guide me in the right direction, not sure where to start.
Since Archetype is too flexible (almost a document type of itself) this is only possible with the recordsimporting/recordimported event. This gives you a list of all the properties that you can set. Then you need to convert that to something ArcheType accepts and you can store it on the document property.
Below a sample. To get this to work you need a reference to Umbraco.Core, CMSImport.Extensions and CMSImport.Library dll's
using CMSImportLibrary.Providers.ImportProviders.Content;
using Umbraco.Core;
using Umbraco.Core.Models;
namespace EventSample
{
public class EventTester :ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentImportProvider.RecordImporting += ContentImportProvider_RecordImporting;
}
void ContentImportProvider_RecordImporting(object sender, CMSImport.Extensions.Providers.ImportProviders.EventArgs.RecordImportingEventArgs e)
{
var doc = sender as IContent;
var prop1 = e.Items["key1"];
var prop2 = e.Items["key2"];
var prop3 = e.Items["key3"];
//Do something with ArcheType
doc.SetValue("ArcheType", your archetypevalue here);
}
}
Import into Archetype
Does anyone have any experience in importing values into archetype using CMSImport.
I need to import 3 values in separate columns of an excel file into an archetype, making each value a separate item. Has anyone ever imported into archetype that could guide me in the right direction, not sure where to start.
Hi Suzy,
Since Archetype is too flexible (almost a document type of itself) this is only possible with the recordsimporting/recordimported event. This gives you a list of all the properties that you can set. Then you need to convert that to something ArcheType accepts and you can store it on the document property.
Below a sample. To get this to work you need a reference to Umbraco.Core, CMSImport.Extensions and CMSImport.Library dll's
}
I hope this helps you,
Richard
Thanks for the response Richard.
is working on a reply...