|
Home > Archive > Commerce Server General > July 2007 > Convert CatalogItem to Product
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Convert CatalogItem to Product
|
|
| bthubbard 2007-07-12, 7:18 pm |
| Rather quick question.
I have conducted a search in Commerce server and now have a
CatalogItemsDataSet. I have tried to iterate through the collection
of CatalogItems via a foreach as so and cast each CatalogItem to a
Commerce Server product as so:
foreach(CatalogItemsDataSet.CatalogItem item in
ACatalogDS.CatalogItems)
{
// Code here to make sure the item is a product,,,,then,,,
Microsoft.CommerceServer.Catalog.Product
tempProduct = (Microsoft.CommerceServer.Catalog.Product)item;
This unfortunatly results in the following compile error : " Error 87
Cannot implicitly convert type
'Microsoft.CommerceServer.Catalog.CatalogItemsDataSet.CatalogItem' to
'Microsoft.CommerceServer.Catalog.Product'"
I have searched around a bit but have not yet found a quick fix.
Thanks.
| |
| Scherzo 2007-07-23, 7:16 am |
| Hi, I do it like this:
Microsoft.CommerceServer.Catalog.CatalogItemsDataSet oProductsFound;
Microsoft.CommerceServer.Catalog.CatalogSearch oSearchObject;
Microsoft.CommerceServer.Catalog.ProductCatalog oCatalog;
Microsoft.CommerceServer.Catalog.Product oProduct;
int i=0;
<... Here configure your search object and initialize objects...>
oProductsFound = oSearchObject.Search();
for (int i=0; i < oProductsFound.CatalogItems.Count; i++)
{
oProduct =
oCatalog.GetProduct(oProductsFound.CatalogItems[i].ProductId);
}
I don't know if it's a good approaching, but it works. 
Scherzo
On Jul 12, 8:57 pm, bthubbard <Brandon.Hubb...@gmail.com> wrote:
> Rather quick question.
> I have conducted a search in Commerce server and now have a
> CatalogItemsDataSet. I have tried to iterate through the collection
> of CatalogItems via a foreach as so and cast each CatalogItem to a
> Commerce Server product as so:
> foreach(CatalogItemsDataSet.CatalogItem item in
> ACatalogDS.CatalogItems)
> {
> // Code here to make sure the item is a product,,,,then,,,
> Microsoft.CommerceServer.Catalog.Product
> tempProduct = (Microsoft.CommerceServer.Catalog.Product)item;
> This unfortunatly results in the following compile error : " Error 87
> Cannot implicitly convert type
> 'Microsoft.CommerceServer.Catalog.CatalogItemsDataSet.CatalogItem' to
> 'Microsoft.CommerceServer.Catalog.Product'"
> I have searched around a bit but have not yet found a quick fix.
> Thanks.
|
|
|
|
|