Archive for August 2008
If your requirement is to show the list of categories and the count of products under that category then there are two approaches for this
1. You can use commerce server object model, get categories for a catalog and for each category, get product count. Populate data in table/object and send it back to front end. Trust me it will take lot of time to fetch these details.
2. You can directly access database and fetch these details. Note: Microsoft doesn’t recommend to access database directly. Here is the code to fetch product count group by category.
Select A.CategoryName, B.Products from [MyCatalog_CatalogProducts] A
Join
(
SELECT [ParentOID]
, Count([OID]) as Products
FROM [MyCatalog_CatalogProducts]
Group by [ParentOID] ) B
On A.OID = B.ParentOID
where CategoryName is not null
If you like this post, please click on our sponsor advertisement.
Commerce server 2007 provides business users to develop six different type of discounts. They are
- Simple Discount
- Minimum purchase discount
- Buy N, Get 1 free
- Paired discount
- Paired set discount
- Order discount
There are some cases where you want to associate a dynamic discount to an Order. In commerce server we have two ways to associate a discount to an order
- When a customer provides a promotion code.
- When a site wide discount is available.
If your requirement is to associate a discount to an order (like 10% off or 20$ off), use following approach to achieve this.
- In code behind, create a discount.
- Add a promotion code to a discount.
- Approve the discount. Note: If you are using discount cache, make sure you call refreshCache method.
- Create a basket and associate the promotion code and perform checkout process.
- Disapprove newly added discount.
- Delete newly added discount.
Here I am not given end to end solution, but throwing some light on the approach. If you feel it is difficult to to know which method to call for which action, you can refer to my blog – http://ravikk.spaces.live.com/blog/cns!F348D7145D1BE6C2!500.entry which explains how to know which commerce server method to call.
If you want to try before you implement in your code, you can refer to quick order code in my blog – it is having code which performs entire checkout at single action (you need to extend it by adding discount creation and deletion code). http://ravikk.spaces.live.com/blog/cns!F348D7145D1BE6C2!428.entry
If you like this post, please click on our sponsor advertisement.
After placing order, there are many cases where the order modification may happen. Commerce server allows us to modify the purchase order but make sure you don’t allow any modifications of purchase after some stage. For example, don’t allow purchase order modification once the ordered products are dispatched. In this article, I am explaining how to remove items from purchase order.
Here is the code snippet used to simulate modifications to an order.
|
OrderContext OrderContext = CommerceContext.Current.OrderSystem; OrderGroupCollection ogCollection= OrderContext.GetPurchaseOrdersForUser(new Guid(userId)); |
For example, I created an order with three products and order total is coming to 221$ (as shown in the figure below.)
In the code, I am taking the order of the user, removing first item from the order, running basket and total pipeline. Note: If you don’t execute pipelines the code will not give any error but the totals will be wrong.
After executing the code the order details are shown below.
A product of price 9$ is removed from the order and the current total is decreased to 212.40$.
If you like this post, please click on our sponsor advertisement.
After installation of starter site, when I open Customer and order manager, I used to get following error.
“Cannot open database “MSCS_Admin” requested by the login.”
| The error in the event log is
Event code: 3005 Application information:
Process information:
Request information:
Thread information: Custom event details: |
The reason for this error is the service account which is running order web service is not having enough previleges on MSCS_Admin database.
If you like this post, please click on our sponsor advertisement.
Commerce server provides flexibility to access its sub-systems using web services. The main drawback is web service documentation – which service to call for a particular action. If you are little bit intelligent, you can achieve this very easily.
Go to IIS and enable logging as shown in the image.
By enabling this functionality, IIS will start logging all hits to web server in the follow location
C:WINDOWSsystem32LogFilesW3SVC1
Note: Make sure you enable method name logging. For more information on enabling IIS logging click on below link
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/b344f84e-bc77-4019-859c-9d483bc85c77.mspx?mfr=true
Now open any commerce server business tool and run any desired action. For example, you would like to approve a discount in marketing system. Just perform that action in business tools and check the log file. you can see which method the business tool has called. Enjoy….
If you like this post, please click on our sponsor advertisement.
