Now here is some actual hands on experience with the commerce server environment…
Well in my last blog, i commented on the commerce server. There is lot of actual coding you can go and see on the msdn help on the commerce server but here on my blog I’ll try and explain those which I think is more usable in what I call a programmatic environment. Now to start off, as I told before the hierarchy goes like the catalog has various categories which has various products.
Note: Now there also are entities called the virtual catalogs and the sub categories which I’ll be discussing at a later point of time probably in my next blog
Everything in Commerce Server 2007 is both programmatic and both in design view, however as a developer I feel that at every point of time there are things that need to be changed in the normal code so as to achieve the desired result. Now trust me, no where in an organization a normal scenario is reached because a software developer is known for designing codes.
Well, firstly I go into
Understanding Catalog Context and the fundamentals of catalogs
How to read a Catalog
Now to Deal with the Catalogs in the Catalog System we have a IDE known as the Catalog Manager. It is a graphical user interface to deal with the catalog and related definitions. Now you must remember that when I am dealing with catalog,category and products, I suppose that the appropriate definitions have been already made as explained in my earlier post. It is done through the Catalog and Inventory Schema Manager. It’s simple to make the definitions, it having a good user interface.
Now the Catalog Context is a entity above catalogs or rather I should say for accessing control to deal with a catalog, you have to use a catalog context object.
On the whole,The Catalog Context object provides the functionality to manage your catalogs. It can be created in one of two modes. These two modes are different in the sense of their declaration.
It can be in local mode, where the code accesses the Commerce Server objects and the database directly and does not use a Web service. Here it uses what is called as the catalogsiteagent. The CatalogSiteAgent class contains configuration for a connection directly to a Commerce Server site's catalog database. So here in the catalogsite agent only by defining the sitename we can actually pull out the whole of catalog context.
Now one of my personal view regarding sitename is to declare sitename in the GlobalConstants.cs file. This is a special feature of the .net 2.0. We had a global.asax in .net1.1 where we used to define global variables, likewise in .net 2.0 we have a class file called Global Constants where if we define a variable we can access this variable anywhere within the solution.
e.g defining
public const string SITENAME = "SumitSite";
in the GlobalConstants.cs file we can use this SITENAME anywhere within the solution.
So by this way of local mode we can get the catalog context.
public static CatalogContext CreateCatalogContextFromSiteAgent()
{
// Create a CatalogSiteAgent to connect to the database.
CatalogSiteAgent catalogSiteAgent = new CatalogSiteAgent();
catalogSiteAgent.SiteName = "StarterSite";
// Create the CatalogContext object.
CatalogContext catalogContext = CatalogContext.Create(catalogSiteAgent);
return catalogContext;
}
Alternatively, it can be in agent mode, where calls to the catalog system are made through the Web service with the help of an agent. Although this method is not used that common because here we inherit a webservice called the CatalogServiceAgent where we have to pass the URL of the service as a parameter.
Now reading a catalog is a very important thing in the catalog system. When we read a catalog, we actually call the inbuilt function of the catalog context called the Get Catalogs. This returns all the catalogs. Similarly we can get the root categories and so on.
private static CatalogsDataSet GetCatalogs(CatalogContext context)
{
return context.GetCatalogs();
}
Now this is the Catalog Part to get the catalogs, there is actually a lot on using the catalog, retrieving a category, product and lots more which will be there in my upcoming blogs. Also check out my other blog http://sumitatlas.blogspot.com, which I’ll be starting today itself.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment