Private Function GetCategoryByDefinition(ByVal product_id, ByVal
category_definiton_name As String, ByVal CatalogWebServiceUrl, ByVal
catalog_name) As String
'initialize the catalog
Dim cat_item As CatalogItemsDataSet.CatalogItem
Dim csa As New CatalogServiceAgent(CatalogWebServiceUrl)
Dim ctxt As CatalogContext = CatalogContext.Create(csa, New
ConsoleDebugContext(DebugMode.Checked))
Dim obj_catalog as ProductCatalog = ctxt.GetCatalog("store")
'get the product from the product_id
Dim obj_product as Product = obj_catalog.GetProduct(product_id)
'get the categories associated with the product
Dim categories As CatalogItemsDataSet.CatalogItemsDataTable obj_product.ParentCategories.CatalogItems
'loop through the categories to find the value of the category that
matches the category defition you'd like to find out if the product
belongs to.
For Each cat_item In categories
Try
'FNull tests for IsDbNull and returns an empty string,
otherwise returns value
If (FNull(cat_item.DefinitionName) = category_def) Then
Return cat_item.CategoryName
Exit Function
End If
Catch
End Try
Next
Leer las respuestas