Posts Tagged ‘tools’

What will happen if you perform rebuild catalogs. As you know, virtual catalogs holds aggregate content from one ore more base/virtual catalogs.  When you add a product from base catalog to virtual catalog, the items in the virtual catalog inherit from base catalog. These relationships can be viewed in the virtual catalog. So, any changes to the base catalog will not be automatically propagated to virtual catalog, unless we explicitly performs rebuild virtual catalog process.

In one of our application there are nearly 40+ virtual catalogs and data is inserted in base catalog by business users. When ever they add products to base catalog, they need to execute “Rebuild All” virtual catalogs from catalog manager.

  • This works fine if they executes rebuild process once at a time. If more than one rebuild operation performs on single catalog, there is huge possibility of SQL deadlocks. If that happens then all future rebuilds will hang and no progress will happen; unless we kill the process (or restart SQL server server service). 
  • The other disadvantage is that frequent building of virtual catalogs will bring the application performance slow.
  • Some times business users modifies the data but forgot to rebuild the virtual catalogs and finally complains that the site is not showing up new products.

To overcome the above problems, first we need to educate the business users on how effectively they can work on the business tools and second, a small utility which will perform rebuild catalogs once in a day. Utility can be developed easily through commerce server API. In the below code sample, we are getting all catalogs from CS, checking if it is virtual catalog or not and performing rebuild process on only virtual catalogs. Based on virtual catalog configuration, the time to complete build process depends, so during that process we should not execute another rebuild process. In below code, I am sleeping the process for two seconds and checking it back whether the process has completed. This process continues till last virtual catalogs gets rebuild.

var catalogsDataSet = catalogSystem.GetCatalogs();
int count = catalogsDataSet.Catalogs.Count;
for (int i = 0; i < count; i++)
{
    var catalogName = catalogsDataSet.Catalogs[i].CatalogName;
    var productCatalog = catalogSystem.GetCatalog(catalogName);
    if (productCatalog.IsVirtualCatalog)
    {
        Console.WriteLine(“Rebuilding…. : ” + catalogName);
        var virtualCatalog = (VirtualCatalog)productCatalog;
        var rebuildProgress = virtualCatalog.Rebuild(true);
        while (rebuildProgress.Status == CatalogOperationsStatus.InProgress)
        {
            System.Threading.Thread.Sleep(2000);
            rebuildProgress.Refresh();
            Console.WriteLine(“Rebuilding In progress… : ” + catalogName);
        }
    }
}

For the system administrator/business users, I have created a tool which perform this task. 

Click here to download

How to use this tool? It is very simple. Download the utility On commerce server machine, open command prompt, navigate to the folder and run the utility from the command prompt.
RebuildAllVirtualCatalogs.exe local <commerce server site name>

If you are running the tool outside of commerce server box then use following command

RebuildAllVirtualCatalogs.exe agent  http://localhost/CatalogWebService/CatalogWebService.asmx

Here is how the utility performs virtual catalog rebuild.

image

 Developers:    Full code version –

Click here to download

Related Articles


If you like this post, please click on our sponsor advertisement.


In commerce server, a basket is created either when the user logs in to the application or when the user tries to add first product to the cart. In reality, in the background we are creating an entry about user basket in transaction database – OrderTemplatesAndBaskets table. All information related to basket such as products, quantity, addresses, etc are stored in a column named “marshaled_data” as Binary large object (BLOB).

Note: You can’t read this data from select query rather you have to use customer and order manager tool to view this binary information.

All baskets will not become purchase orders. So, in an enterprise application with more than a million customers, you can see many unnecessary baskets created in the system. It is good practice to remove unnecessary baskets periodically. We have few ways to do it.

1. Simple and Ugly way: Delete unwanted data directly from OrderTemplatesAndBaskets table.

Delete OrderTemplatesAndBaskets Where LastModified <=  DATEADD (d, -30, GetDAte())

2. Use PurgeCommerceData.exe tool that comes out of box from commerce server. The syntax is

PurgeCommerceData <site_name> flag [options]

For example, the below command purges all baskets that are been unchanged for last 30 days.

PurgeCommerceData site_name -b -d 30

Note: This option only works on the system where commerce server installs

3. Some times, we may have to run this tool from remote system (not on the production server directly) and in those situations, we can use commerce server agent mode API to perform this task. The below code snipped can be used to delete the baskets. You can create a service to do this clean up job regularly or create command line utility and schedule to run that utility on specific intervals.

string orderWebServiceUrl = "http://server/OrdersWebService/OrdersWebService.asmx";
DateTime agingDate = DateTime.Now.AddDays(-30);
var serviceAgent = new OrderServiceAgent(orderWebServiceUrl);
OrderManagementContext context = OrderManagementContext.Create(serviceAgent);
BasketManager basketManager = context.BasketManager;

// Create a search clause.
DataSet searchableProperties = basketManager.GetSearchableProperties(CultureInfo.CurrentUICulture.ToString());
SearchClauseFactory searchClauseFactory = basketManager.GetSearchClauseFactory(searchableProperties, "Basket");
agingDate = agingDate + DateTime.Now.TimeOfDay;
SearchClause clause = searchClauseFactory.CreateClause(ExplicitComparisonOperator.OnOrBefore, "Created", agingDate);

// Delete baskets that match the conditions.
int recordsDeleted;
basketManager.DeleteBaskets(clause, out recordsDeleted);

Related Articles


If you like this post, please click on our sponsor advertisement.


Two years back, I have blogged catalog importer, which will help us to import catalog data into commerce server. I have used this tool in many projects and business users like this tool as it uses excel as input parameter. Recently I see in communities asking for user profile import. User profile has some sensitive information (like password, secret question and answer, etc) and we can’t directly insert these data into database as these data should be encrypted using few algorithms (SHA1, SHA256, MD5, etc) before saving into database.

If your requirement is to import all existing user profiles then the good option is to insert data using commerce server API. I created a tool (simple and robust) which will help you to insert user profile (can extend to save address and other profiles) information in commerce server. The tool is very flexible and extensible without touching the code. Input to this tool is the excel file (sample file in data folder) and couple of constraints with this template are.

  • The work sheet name should be “UserData”.
  • Currently only 5 columns are there but you can extend the list – the column name should be same as commerce server column name. For example, if you want to import telephone number then the column name should be “GeneralInfo.tel_number”.

The code is pretty simple and self explanatory. When you run the tool, you will be prompted for excel file location. After providing the information, the tool loads data into data table and starts inserted data one by one into commerce server. The output of the tool looks like this (I have imported the sample data in the sample template file). Any wrong information in excel will lead to exception.

image

On successful import, if you query “UserObject” table (or other profile tables), you can find imported data.

image

Click here to download the tool.

Related Articles


If you like this post, please click on our sponsor advertisement.


Working in SharePoint is very interesting and challenging. Sometimes we end up doing only application configuration (setting up the application ready for development) rather than delivering the functionality. In recent days, I have faced similar problem. I was working on commerce server extended SharePoint kit and changes done to the kit need to be deployed the assemblies in GAC. If I missed redeployed, I am not able to test the code functionality.

I have developed a small and tiny utility to deploy updated assemblies (dll) very easily into GAC. It is simple but cumulatively it has saved lot of time. Here is the screenshot of the tool.

Quick GAC deployer

Click here to download

In order to make this tool work, we have to set three values in configuration file.

  1. assemblyPath –the path of assembly (by default it will be c:\windows\assembly).
  2. dllPath – your application bin folder.
  3. gacUtilPath – GAC Utility path – c:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\Gacutil.exe

That’s all, the tool is ready for usage. Drop me an email if you have any issues with this tool.

Related Articles


If you like this post, please click on our sponsor advertisement.


Most of the medium and small ecommerce application support generic order process where the user has to add their products to shopping cart, manually checkout the basket, provide shipping, billing addresses and payment details. This is five page refresh process. The process will be applicable to the customer who wants to buy more products at once. Most of the customer will buy single product at a time and only few customers will perform bulk orders. To help single purchase buyers, we can implement Quick order.

Quick Order (or single click ordering) is a very useful and powerful tool and can be built for ecommerce customers and customer service representatives (CSR), who works from back office.  By allowing customer to make their purchase quickly and in reduced steps will encourage them to come back and make another purchase in the future.  CSR can reduce the call time with the customer if s/he can order the product in reduced steps which improves efficiency.  Quick order application via the automated IVR system can provide 24×7 accesses for customer to purchase on phone. Quick order process will work well with the registered user and may/may not work with anonymous user.

Registered User:
View Product -> Click Quick Order button -> Order confirmation (if required) – > Order Display

Non-register user:
View Product -> Click Quick Order button -> Accept Billing & Shipping Address -> Accept Payment  -> Order confirmation (if required) – > Order Display For quick order process, we have to do some customizations in commerce server.

  1. Extend commerce server profile System to capture following details
    1. Default billing address 
    2. Default shipping address.
    3. Default Payment Method.  
    4. Default Credit/Debit card (if payment method is credit card)  
  2. In the registration form, try to accept following details from the customer
    1. Billing address
    2. Shipping address
    3. Payment details

The application can use the information available in the user profile while performing quick checkout. So, when the user clicks on quick check button on product page, the following actions should take place.

  1. Input Values expected from UI – User Id, Catalog Name, and Product Id.
  2. Retrieve commerce server context of catalog, order and profile subsystems.
  3. Create new basket.
  4. Retrieve user profile properties like address Id, credit card Id, etc.
  5. Retrieve product details from Catalog subsystem and populate into basket.
  6. Retrieve address details from profile subsystem and populate into basket.
  7. Retrieve payment details (credit card) from Order subsystem and populate into basket.
  8. Execute pipelines in the following order and then convert basket into Purchase Order.  
    1. Basket  
    2. Total  
    3. Checkout  

Click here to download Quick checkout code

Related Articles


If you like this post, please click on our sponsor advertisement.


Follow me on Google+
Couldn't get data from google+
Sign up for Newsletter