How can i see all categories??help help help!!!
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 > How can i see all categories??help help help!!!




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

    How can i see all categories??help help help!!!  
jorge


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


 
07-09-04 08:11 PM

Hello!!
i´m develop a web site with commerce and i need see all categories to create
a browse page.
how can i create a loop that cross all categories, please help me!!! is very
important!!







[ Post a follow-up to this message ]



    RE: How can i see all categories??help help help!!!  
Austin Skyles [MSFT]


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


 
07-09-04 08:11 PM

The included code will traverse over all categories in the Catalog
"Adventure Works Catalog" and print out the categories. You can adapt this
code to be used in a your web page.

using System;
using System.Data;
using Microsoft.CommerceServer.Runtime.Catalog;
using Microsoft.CommerceServer.Runtime.Diagnostics;

namespace ListCategories
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class ListCategories
{
static string connectionString = "Provider=SQLOLEDB.1;Integrated
Security=SSPI;Initial Catalog=\"CSharpSite_commerce\";Data Source=.;";
static string catalogName = "Adventure Works Catalog";

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
CatalogContext context =
CatalogContext. CreateFromConnectionString(connectionStr
ing, new
ConsoleDebugContext(DebugMode.Production));
ProductCatalog pc = context.GetCatalog(catalogName);
DataSet rootCategories = pc.GetRootCategories();
foreach(DataRow row in rootCategories.Tables[0].Rows)
{
ShowCategory(pc, row["CategoryName"].ToString(), 0);
}
}

static void ShowCategory(ProductCatalog pc, string categoryName, int
depth)
{
for(int i=0;i<depth;i++)
{
Console.Write(" ");
}
Console.WriteLine("Category: {0}", categoryName);

Category cat = pc.GetCategory(categoryName);
DataSet categories = cat.GetChildCategories();

foreach(DataRow row in categories.Tables[0].Rows)
{
ShowCategory(pc, row["CategoryName"].ToString(), depth+1);
}
}
}
}


Austin Skyles


This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Get Secure!  For more info visit http://www.microsoft.com/security.
Please reply to the newsgroups only.  Thanks


--------------------
Reply-To: "jorge" <agujas3@hotmail.com>
From: "jorge" <agujas3@hotmail.com>
Subject: How can i see all categories??help help help!!!
Date: Wed, 7 Jul 2004 09:29:05 +0200
Lines: 7
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.0
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.132
Message-ID: <#hdJZQ$YEHA.648@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.commerceserver.general
NNTP-Posting-Host: 202.red-80-38-81.pooles.rima-tde.net 80.38.81.202
Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXS01.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP0
8.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.commerceserver.general:14203
X-Tomcat-NG: microsoft.public.commerceserver.general

Hello!!
i´m develop a web site with commerce and i need see all categories to create
a browse page.
how can i create a loop that cross all categories, please help me!!! is very
important!!








[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:37 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