Thursday, September 13, 2007
Setting Up Profile System In Commerce Server 2007
Profile System
Now, in this blog I will explain the process of registration.
Firstly we provide a UserId. In my case i am using a asp.net User registration Wizard
// Set new user id. CommerceContext.Current.UserID = ((Guid)Membership.GetUser(UserRegWizard.UserName).ProviderUserKey).ToString();
Then we set the Commerce Profile :
commerceProfile.Profile currUserProfile = objUpmProfileProvider.GetCommerceProfile("GeneralInfo.email_address", TbxUserEmail.Text.Trim(), "UserObject");
Commerce has inbuilt Properties, you can make new properties using the Commerce Manager.
I will explain this in detail in another blog.
So Now we can set various properties of the commerce like
currUserProfile["GeneralInfo.first_name"].Value = userFirstName.Text.Trim();
After Setting the Properties to store it we do.
currUserProfile.Update();
Hence we just created a new user.
Hope the post is helpfull.
Wednesday, January 24, 2007
Catalog Search Over Explicit Search
Pulling Out the Catalog Context
return CommerceContext.Current.CatalogSystem;
So hence we see that instead of explicit catalog context call, we can directly initialize the catalog context. This may seem to be a very small thing, but on the contrary if your application is big enough, it will certainly boost up the speed of the application. This is due to the fact that if you explicitly call the catalog content using the siteagent i.e by doing:
//Create a CatalogSiteAgent to connect to the database.
CatalogSiteAgent catalogSiteAgent = new CatalogSiteAgent();
catalogSiteAgent.SiteName = "Give the appropiate sitename";
//Create the CatalogContext object.
CatalogContext catalogContext = CatalogContext.Create(catalogSiteAgent);
return catalogContext;
By doing this, you may get the same catalog context, however it may be initialized n number of times for n number of calls. Hence the first method is quite efficient and effective.
Monday, October 30, 2006
Pulling Out Data from Catalog System
Seach Clause Factory : In search clause, we usually find a product using the Catalog Name, the Category Name, and the Search Clause. To do this we usually do the following :
CatalogItemsDataSet catItemDs = new CatalogItemsDataSet();
CatalogSearch catalogSearch = CommerceContext.Current.CatalogSystem.GetCatalogSearch();
CatalogSearch.CatalogNames = "TheCatalogName";
CatalogSearch.CategoryName = "TheCategoryName";
CatalogSearch.SearchOptions.ClassTypes = CatalogClassTypes.ProductClass;
// set the search creitera
CatalogSearch.SqlWhereClause = "Item1 = '" +value + "'";
// Here we specify the condition for which the search has to be done.
// returns CatalogItemsDataSet
catItemDs = catalogSearch.Search();
//to get the desired properties
Here we get the desired properties of the products.
The Second and the most simple way of getting the product out the catalog System is through specifying the ProductId, and the Catalog Name. We do this in the following manner :
Product p = cc.GetProduct(CatalogName, ProductId);
After this we can get the value of the properties of the products
Thursday, October 19, 2006
Business Logic
Each and every Control requires business logic which in programming language is called a Business Object. This is done in order to maintain the balance between the business layer and the data layer so as to efficiently use the data in the custom controls.
Working : Whenever we create a custom control ( a .cs file), we never call the database or the commerce server API in the control itself. Instead we follow a hierarchy.
There are three files in the working of a control which all exists in the App_Code folder of the Solution.
1. The Data Provider: This is the actual code file which deals directly with the commerce server API or the database indirectly. The main function of the data provider is to get the data from the commerce server API and give this data to the business logic or the business object.
2. The Business Object: This File plays a very important role as not only it takes in the required data from the data provider, but on the other hand gives this data to the custom control.
3. The Custom Control: The most important is the custom control which defines the look and feel of the control utilizing the data given by the business object
A good elaboration would be :
----> Business Object ( BO.cs)
Class BO
{
Private string m_name;
Public string name
{ get{ return m_name;} set{ m_name = value;}
}
----> Data Provider ( DP.cs)
Class DP
{
Public void dataprovider ( string CatalogName, string ProductId)
{
// cc = commerce context
Product P = cc.GetProduct( CatalogName, ProductId);
BO BusinessItem = new BO();
BusinessItem.name = p.Information.CatalogItems[0].Table.Rows[0]["Name"].ToString();
Return BusinessItem;
}
}
----> Custom Control ( CC.cs)
Class CC
{
BO BItem = new BO;
DP Dprovider = new DP;
BItem = DP.dataprovider ( CatalogName, Product Id);
Label L1 = new Label();
L1.Text = BItem.name;
}
So Hence we see, how we use a Data Provider and Business Object to be used in the custom control. This approach makes the logic flow very good.
Monday, September 18, 2006
The Catalog Context
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.
Sunday, September 10, 2006
The Catalog System- A Brief Overview
This means that without interacting with the SQL server you can actually build the whole website.
A more elaboration on the topic will be that a catalog is nothing but a data entity at a large level. It is subdivided into categories and products.
CATALOG à CATEGORY à PRODUCT
This means that a catalog can be divided into several categories and each category can have various products. This is the main fundamental of the catalog system in the commerce server 2007.
Take an example of a large shopping mall site. The mall would certainly have a book store. So say we created a catalog for books.
In the Commerce Server Catalog Manager we go and make a new Catalog called Books. So the books can be said to be a catalog. The internet books, java books, novels, classics are the category of books whereas a particular book as in Unleashed .net 2.0 is a product. So here we see how the whole thing is so much sub-divided as to make things simpler. Now the question is what are the attributes and on what parameters each of these are made. So, here comes the role of the schema. For one minute just leave the example and lets study how the schema of an entity is handled in the commerce server.
XML data is considered to be favorite among some people as they say it is more structural data. Creating a xsd structure of the data is a very popular way of dealing with XML. Similarly the commerce server 2007 introduces the catalog and inventory schema manager. This manager gives the power to populate various structures or schema for various definitions of the catalog System. It is mainly divided into three parts. Let’s start from the smallest entity definition to a bigger one.
Property Definitions: The property definition gives the power to define properties. These are the Attributes of a Product in the catalog System. The Property is the smallest entity that is there is the catalog system. The property is a attribute of a product. For example for a particular book we have title and author, all these are the properties of a product.
Product Definitions: The Product Definitions is what the schema for a particular product is. This means that when we start to make a product then the catalog system asks for a product definition. This is basically the attributes of a product.
Note: Please don’t ge6t confused between the two definitions. The property definition is the general definition for all the attributes in the entire catalog system whereas the product definition is restricted to the schema for a product. It means that the product definition is mainly for a specific product whereas a property is a different universal thing. Moreover on creating a product definition we get a a property list to choose properties to make a schema for a product definition.
Category Definition: A category definition also involves choosing from a list of properties; On the contrary here we are selecting properties for the attributes of a specific category.
This was an abstract of what the Catalog System is in the Commerce Server 2007.
The Commerce Server introduces many such systems which are very beneficial for making good ERP sites. My next post will give you an idea of the coding involved in Catalog System.
The Start has begun
Sumit
