Convert CatalogItem to Product
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Commerce Server > Commerce Server General > Convert CatalogItem to Product




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Convert CatalogItem to Product  
bthubbard


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-13-07 12:18 AM

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.






[ Post a follow-up to this message ]



    Re: Convert CatalogItem to Product  
Scherzo


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-23-07 12:16 PM

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.







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:55 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register