‘Add product Types (sub categories)
Dim catalogApi
As New CatalogEntryApi()
Dim productTypeApi
As New ProductTypeApi()
Dim inventoryAPI
As New InventoryApi()
Dim dr As SqlDataReader
Dim currentUserId As Long = catalogApi.UserId
Dim Currency_USD As Integer = 840
‘ Create and Populate ApplicantDetails
If currentUserId > 0 Then
Dim folderId As Long = 0
Long.TryParse([folder id], folderId)
Dim productTypeId As Long = 0
Long.TryParse([product id], productTypeId)
Dim price As Decimal = 0
Decimal.TryParse(txtprice.text.ToString().Trim(), price)
Dim entryData As EntryData = Nothing
Dim entryType As Ektron.Cms.Common.EkEnumeration.CatalogEntryType = productTypeApi.GetItem(productTypeId).EntryClass
Select Case entryType
Case Ektron.Cms.Common.EkEnumeration.CatalogEntryType.Kit
entryData = New KitData()
entryData.LanguageId = catalogApi.ContentLanguage
Exit Select
Case Ektron.Cms.Common.EkEnumeration.CatalogEntryType.Bundle
entryData = New BundleData()
entryData.LanguageId = catalogApi.ContentLanguage
Exit Select
Case Ektron.Cms.Common.EkEnumeration.CatalogEntryType.SubscriptionProduct
entryData = New SubscriptionProductData()
entryData.LanguageId = catalogApi.ContentLanguage
Exit Select
Case Else
entryData = New ProductData(catalogApi.ContentLanguage)
Exit Select
End Select
entryData.Title =
entryData.TaxClassId =
entryData.Sku =
entryData.GoLive =
entryData.EndDate =
entryData.CurrencyId = Currency_USD
entryData.ProductType = New ProductTypeData()
entryData.ProductType.Id = productTypeId
entryData.Pricing = New PricingData(Currency_USD, price, price)
entryData.FolderId = folderId
entryData.Html = "Other " & txtclassname.text & _
" " & txtDescription.text & " "
Try
catalogApi.Add(entryData)
lblMessage.Text = lblMessage.Text & "
Entry Saved. ID: " & entryData.Id
Dim inventoryData As New InventoryData()
inventoryData.EntryId = entryData.Id
inventoryData.UnitsInStock =
Try
inventoryAPI.SaveInventory(inventoryData)
Dim tax As New Taxonomy()
Dim itemRequest As New TaxonomyContentRequest()
itemRequest.TaxonomyList =
itemRequest.ContentId = entryData.Id
‘Assign productID
Try
tax.AddTaxonomyItem(itemRequest)
Catch ex As Exception
lblMessage.Text = lblMessage.Text & "
An error occured while saving the taxonomy.
" & ex.Message
End Try
Catch ex As Exception
lblMessage.Text = lblMessage.Text & "
An error occured while saving the inventory.
" & ex.Message
End Try
Catch ex As Exception
lblMessage.Text = lblMessage.Text & "
An error occured while saving the entry.
" & ex.Message
End Try
Else
lblMessage.Text = "Not logged in."
End If