Wednesday, February 23, 2011

Price OverRide feature for price drop

Out of the box the price override feature is used in the Sales center to override the price by an admin.

This feature is really easy to customize for requirements such as price drop , to show some discount and implement as a price override. There is a bit for price override that needs to be set to let the performance engine make aware there is a price override on a orderitem.

int currentPrepFlag =orderItems[i].getPrepareFlagsInEJBType().intValue();
currentPrepFlag |=OrderConstants.PREPAREFLAGS_PRICE_OVERRIDE;
orderItems[i].setPrice(String.valueOf(finalprice));
orderItems[i].setPrepareFlags(new Integer(currentPrepFlag ));
orderItems[i].commitCopyHelper();

Tuesday, February 22, 2011

External/Custom promotions loader for WCS

This article is more relevant for 6.0, As I am not sure, how much Management center makes it easier to create promotions and how much effort does it take compared to Accelerator. I did work on some on POC for management center and found it relatively easier to accelerator.

Promotion engine is really powerful and Accelerator only has limited functionality exposed.In the past I have worked on loading new promotion types that are supported by promotion engine using loading via spreadsheets and also same approach can be used to load external promotions into WCS.

The promotions loader essentially has to put entries and XML into the following tables.
PX_PROMOTION
PX_GROUP
CLCDPROMO
CALCODE
CALCODEDSC
CATENCALCD --product promotions
CATGPCALCD--category promotions

It is still a maintenance struggle from what I have seen in production for a couple of years but the functionality is not that hard to implement and these promotions are visible in Accelerator and can be disabled or deleted but these could not be edited in Accelerator because they were for created for custom features that had no OOB Accelerator support.

Tuesday, February 15, 2011

DynaCache problem ! Any Exception will result in not caching response

IBM run time has underlying low level logic to designate a page/entry uncacheable in the event of any system exception. Even if the system exceptions are caught from custom code. It still ends up not caching the entry.
e.g.
If you have any extra parameters in the URL that could cause any exceptions. The output of the servlet is not cached.

Do make sure before passing parameters to OOB commands beans. Validate the ID's that will help for some cases.

Tuesday, January 25, 2011

Policy For Stacking Shipping promotions

If you have a client that requires multiple shipping promotions to be applied on an order.
By default there can only be 1 shipping promotion applied on any order.

1). update px_policy set status = 1 where name in ('Shipping: Any order item can only participate in one promotion') and store_id = STORE_ID
2). Get the xmlparam data for this policy: select xmlparam from px_policy where name in ('Shipping: Any order item can only participate in one promotion') and store_id = STORE_ID
3). Update the xmlparam
Before:
<PromotionPolicy impl="com.ibm.commerce.marketing.promotion.policy
.EachItemCanParticipateInPromotionOncePolicy"
&.......;/StoreKey></PromotionPolicyKey><Status>Active</Status></PromotionPolicy>
After:
<PromotionPolicy impl="com.ibm.commerce.marketing.promotion.policy.
EachItemCanParticipateInPromotionOncePolicy"&
.........;</StoreKey></PromotionPolicyKey><Status>Inactive</Status></PromotionPolicy>

4). restart the server

Internal Server Error during Order Process

Internal Server Error or HTTP error 500. Any time you see this error, it generally means web server is not able to fulfill the request.
Scenario: The B2B system that I was working on talks to SAP for order fullfillment and placement. clicking order review, it was throwing exception during invocation of method "flush" on bean "BeanId(WC_LIVE#Enablement-BaseComponentsData.jar#ServerJDBCHelper, null)". Exception data: javax.ejb.EJBException: nested exception is: javax.ejb.EJBException: executeUpdate returned zero rows updated.

All the energies were spent from checking DB locks to implementation of optimistic locking to double click handler on client/server but finally figured out the problem was if the response was not within 40 sec(ServerOTimeout="40") webserver was marking appserver down and it was throwing internal server error.
Resolution:
we Increased the serverIPTimeout to 300 seconds in plugin-cfg.xml
Before: LoadBalanceWeight="20", ServerIOTimeout="40"
After: LoadBalanceWeight="2", ServerIOTimeout="300

Monday, January 24, 2011

How to make application server pickup content from WebServer

Web server Plug-in is smart to route, if a request is to be sent to Application Server or Web Server.

In order for web server to serve the static content for the stores module,
the conf folder of the web server has the configuration file e.g. httpd.conf or httpd-live.conf
All the relevant virtual hosts need to be updated with an alias e.g. /www/public/static can be any path on the web server file system.

Alias /wcsstore "/www/public/static"

Best practice for static content path:
e.g.
www.mycommercestore.com/wcsstore/MyStorefrontAssetStore/img/en_US/718x407/remote.gif
www.mycommercestore.com/wcsstore/SecondStorefrontAssetStore/img/en_ES/718x407/remote.gif
These paths would get resolved to the following physical locations.
/www/public/static/MyStorefrontAssetStore/img/en_US/718x407/remote.gif
/www/public/static/SecondStorefrontAssetStore/img/en_ES/718x407/remote.gif

It is a good practice to have a folder hierarchy properties such as store name, locale and would greatly help when there are multiple stores and/or languages.

Sunday, January 23, 2011

Dynamic contact pricing for guest shoppers

There are 3 kinds of users in commerce from front end when accessing the site.
1. Guest : Guest user does not have password but has unique id
2. Generic : Generic user id is used -1002 most of the times.
3. Registered. : A guest user is converted into a registered user.

IBM web sphere commerce has a very powerful contract model and I have worked on B2B and B2C projects, where we have used contract model to define price and product filters.
For the B2C model for EPP and EDU, we use the contract price.

FOR EPP/EDU for users
Once a contract is successfully created and a contract can be assigned to a group of users using MBRGRPMBR
PARTICIPNT is used to associate a MBRGRP to a contract.

1. MBRGRP
2. MBRGRPMBR.
3. PARTICIPNT

For EPP: Usually the guest users are not allowed to see the pricing and requires logging in.
for EDU: To allow guest users to see contract pricing, One approach that we used was to add the guest users to add to PARTICIPNT table.

These are the most important contract tables from the data model.
1. PRODUCTSET
2. PSETADJMNT
3. TERMCOND
4. TRADING
5. TRADEPOSCN
6. OFFER

Important queries:

select c.name, a.productset_id, adjustment, xmldefinition from atcmr.psetadjmnt a, termcond b, contract c, d
where a.termcond_id = b.termcond_id and c.name = 'CONTRACTNAME' and b.trading_id = c.contract_id and c.state = 3 and adjustment = -5
and d.productset_id = a.productset_id