API
Version 7.x > API > Create Document Types programmatically View modes: 
User avatar
Member
Member
thanos.panousis-indice - 3/4/2013 4:10:57 PM
   
Create Document Types programmatically
Our client has an ecommerce website migrating to Kentico. Currently there are around 300 different product types being sold--too many to create by hand.

Could you post some guidance on how to create DocumentTypes programmatically? Ideally, the new doc types should be "Products" (in the Kentico eCommerce module sense) and inherit fields from a base product type, which will hold all base fields needed.

I have already looked into this KB article: http://devnet.kentico.com/Knowledge-Base/API-and-Internals/How-to-clone-a-document-type.aspx . Unfortunately most of the code doesn't work on kentico 7, specially the CMS.DataEngine.TableManager parts.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/4/2013 6:14:34 PM
   
RE:Create Document Types programmatically
Hi,

You need to reflect the API changes in v7 and the idea from that KB is still the same.

Also, this may be helpful for you too: products import - but you need to reflect the API changes as well (there is v6 sample available).

Best regards,
Juraj Ondrus

User avatar
Member
Member
thanos.panousis-indice - 3/10/2013 11:55:17 AM
   
RE:Create Document Types programmatically
The product import pointer helped a lot, thanks. I now have 300(!) new document types in my installation.

My next problem is setting up correct controls for field appearance. Say that I have a field that should become a dropdownlist, with specific options eg 1;blue, 2;red etc.

What are the correct API calls I need to make in order to register this control in my new document type?

User avatar
Kentico Support
Kentico Support
kentico_radekm - 3/11/2013 1:21:00 AM
   
RE:Create Document Types programmatically
Hello.

You can follow this article from our Developer's guide dealing with the very same task: http://devnet.kentico.com/docs/devguide/developing_form_controls.htm

Best Regards,
Radek Macalik

User avatar
Member
Member
thanos.panousis-indice - 3/11/2013 6:41:10 AM
   
RE:Create Document Types programmatically
kentico_radekm wrote: Hello.

You can follow this article from our Developer's guide dealing with the very same task: http://devnet.kentico.com/docs/devguide/developing_form_controls.htm

Hello Radek,

I am not interested in creating a new, custom control. What I am trying to do is to programmatically create a Document Type that contains fields of type "Dropdownlist". I have found out what api calls to make in order to add a simple input field, but can't find anything on adding a dropdownlist-type field.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 3/11/2013 2:50:24 PM
   
RE:Create Document Types programmatically
Check out this KB article. I think what you are looking for is
FormFieldnfo.FieldType = CMS.FormEngine.FormFieldControlTypeEnum.DropDownListControl
and
FormFieldInfo.Settings["options"]