Welcome to the IBM Websphere Commerce Hub


Welcome to the IBM Websphere Commerce Hub

Come join me in my journey to explore the various features and capabilities of IBM Websphere Commerce and understand how retailers can benefit from its really cool out-of-box functionality.

Showing posts with label websphere commerce foundation. Show all posts
Showing posts with label websphere commerce foundation. Show all posts

Monday, April 7, 2014

Debugging BOD Framework

Important Trace Strings to debug BOD


BOD Request / Response:  

com.ibm.commerce.foundation.server.command.bod.*

Data Service Facade Trace String: 

com.ibm.commerce.foundation.server.services.dataaccess.DataServiceFacade 

Get Service Flow Trace Strings:

Useful to understand if the code is breaking midway and if you would like to enable tracing for individual commands.

Fetch<ComponentName>Cmd 

The first point to debug the Get / Search service failures. 
The Fetch command fetches the data.Extensions of this Fetch command are associated with a particular XPath expression.The command framework can use the XPath expression and Fetch task command to resolve the Get request to a particular implementation by using the existing WebSphere Commerce command registry (CMDREG) data. Instead of having one implementation for a Fetch business task, the command framework uses the XPath as the selector to resolve the implementation. If a specific implementation is not defined for the given XPath, then a default Fetch is used.

For example , The InventoryAvailability noun uses a default Fetch implementation and to debug , you must enable the trace for :



com.ibm.commerce.inventory.facade.server.commands.FetchInventoryAvailabilityForDKCmdImpl
 
Compose<ComponentName>Cmd 

The Fetch Command calls the Compose commands to composes the response.When the Get command calls the Compose command, it uses the access profile of the request as the key to select the appropriate Compose implementation. Because the access profile is just a superset of another access profile, the Compose commands delegates to the parent access profile to first populate the logic model and add any required information.

For example , The InventoryAvailability noun uses the below Compose implementations and to debug , you must enable the trace depending on the Inventory system used :



DOMInventorySystem com.ibm.commerce.inventory.facade.server.commands.ComposeDOMInventoryAvailabilityForDKInBatchCmdImpl

NonATPInventorySystem
com.ibm.commerce.inventory.facade.server.commands.ComposeNonATPInventoryAvailabilityCmdImpl

ATPInventorySystem
com.ibm.commerce.inventory.facade.server.commands.ComposeATPInventoryAvailabilityForDKCmdImpl
 
ReadBusinessObjectMediators 

The read mediator constructs the logical object based on the values in the corresponding physical entity.The Read mediators can be found by looking at the below file:



/WC/xml/config/<component-name>/wc-business-object-mediator.xml


For example , The InventoryAvailability service debugging , enable the trace for the below :
com.ibm.commerce.inventory.facade.server.services.dataaccess.bom.mediator.ReadInventoryAvailabilityMediator  
If you do not wish to enable the trace on a granular level , you could also enable the trace for the entire component service.

For example , for Inventory services , enable the below trace :
com.ibm.commerce.inventory.facade.server.*

Debugging Query Template File


XPATH Syntax Validator (wcs_xpathkey utility):

The XPath key generator command-line utility takes an XPath expression as input and generates an XPath key. This key is used to locate the XPATH_TO_SQL_STATEMENT template in the query template file.This utility can help you validate the format of the XPATH Key as well such as missing closing brackets etc or misplaced tokens. Please note this would not however match the XPATH with the actual Noun definition.

wcs_xpathkey MyXPath
For example:
wcs_xpathkey /CatalogEntry[(@catalogEntryTypeCode='ProductBean' 
  or @catalogEntryTypeCode='ItemBean') and 
   ParentCatalogGroupIdentifier[ExternalIdentifier[GroupIdentifier='Coffee Table']]]

The output from this command , if sucessful, would be:
/CatalogEntry[(@catalogEntryTypeCode=) and 
   ParentCatalogGroupIdentifier[ExternalIdentifier[GroupIdentifier=]]]

In case of failures , would display certain error messages.

Query Template File Syntax Validator

Use this page to validate your query template file syntax.
http://localhost/webapp/wcs/admin/servlet/dsl.jsp

In case you are seeing NullPointer exceptions on querying even the OOB services, make the below changes in the dsl.jsp.

Search for the below line:
sc.setXPath(sbQuery.toString());

Add the following line of code below the above line:
sc.setComponentId(componentId); 

Reloading the configuration of a BOD service module

During development, you may want to modify and reload configuration, without having to restart the server. Follow the below Infocenter link  for more details:


http://pic.dhe.ibm.com/infocenter/wchelp/v7r0m0/topic/com.ibm.commerce.developer.soa.doc/tasks/tsdreloadconfig.htm

Monday, April 16, 2012

Day 4 : Demo - Creating short SEO URLs for new static views

Let us revisit and do some practical based on the concepts learned on Day 1 to Day 3.

In this demo tuturial , we will create a short SEO friendly URL for a custom view that we have created "SuggestionsComplaintsView" using the WCS 7 SEO Pattern mapping files in simple 3 steps.

We will change the long WCS URL
http://localhost/webapp/wcs/stores/servlet/SuggestionsComplaintsView?storeId=10051&catalogId=10051&langId=-1
to
Short Search Engine optimized URL
http://localhost/webapp/wcs/stores/servlet/en/madisons/suggestion-complaints

Pack up your energy drinks and lets sprint into the SEO world. I hope you will find it in useful.

Demo Video:


Help Section:

The JSPs and XMLs used in this demo can be downloaded from this link.

Pattern Definition made in the SEOURLPatterns-ext.xml

<seourl:seoUrlConfiguration
    xmlns:seourl="http://www.ibm.com/xmlns/prod/commerce/foundation/SEO/URLPattern"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/
SEO/URLPattern wc-seo-url-pattern.xsd">
    <!--
        SuggestionComplaints URL like this:
http://localhost/webapp/wcs/stores/servlet/en/madisons/suggestion-complaints    -->
    <seourl:seoUrlPatternDef name="SuggestionComplaintsURL">
        <seourl:seoUrlPattern viewName="SuggestionsComplaintsView">/LanguageToken/StoreToken:CatalogToken/SuggestionComplaintsToken</seourl:seoUrlPattern>
        <seourl:urlToParamMapping>
            <seourl:mapping name="langId" value="?LanguageToken?" />
            <seourl:mapping name="storeId" value="?StoreToken?" />
            <seourl:mapping name="catalogId" value="?CatalogToken?" />
        </seourl:urlToParamMapping>
        <seourl:paramToUrlMapping>
            <seourl:mapping name="LanguageToken" value="?langId?"
                defaultValue="-1" />
            <seourl:mapping name="StoreToken" value="?storeId?" />
            <seourl:mapping name="CatalogToken" value="?catalogId?" />
            <seourl:mapping name="SuggestionComplaintsToken" value="SuggestionComplaintsToken" />
        </seourl:paramToUrlMapping>
        <seourl:usageDef CMCPrefix="true">
            <seourl:usage device="browser">
                <seourl:target>SuggestionComplaints</seourl:target>
            </seourl:usage>
        </seourl:usageDef>
    </seourl:seoUrlPatternDef>
</seourl:seoUrlConfiguration>

SQL Executed
insert into seotokenusgtype (tokenusgtype_id, tokenusgtype, primarytoken,storeent_id, isstatic) values ((select counter+1 from KEYS where tablename='seotokenusgtype') , 'SuggestionComplaints', 'SuggestionComplaintsToken',<store-id>, 1);
update KEYS set counter=counter+1 where tablename='seotokenusgtype';
insert into seourl (seourl_id, tokenname, tokenvalue) values ((select counter+1 from KEYS where tablename='seourl'), 'SuggestionComplaintsToken', 'SuggestionComplaintsToken');
insert into seourlkeyword (seourlkeyword_id, seourl_id, storeent_id,language_id, urlkeyword, status) values((select counter+1 from KEYS where tablename='seourlkeyword'), (select seourl_id from seourl where tokenname='SuggestionComplaintsToken'), <store-id>, -1, 'suggestion-complaints', 1);
update KEYS set counter=counter+1 where tablename='seourl';
update KEYS set counter=counter+1 where tablename='seourlkeyword';


Related Blogpost
Smarter SEO for Smarter Commerce

Sunday, April 15, 2012

Day 1 : Introducing "wcf:url" tag


To avoid having to hard code SEO friendly URLs in the storefront pages, the WebSphere Commerce Search Engine Optimization feature provides a wcf:url tag that will construct SEO friendly URLs using the SEO pattern file(s) and tables.

The current wcf:url tag is used by all starter stores to construct SEO friendly URLs. The UrlTag class has been enhanced to support the use of the new URL pattern definition to create SEO friendly URLs.

Incase you open any JSP , for example CachedFooterDisplay.jsp, you will notice that our old friend <c:url> tag which was used to construct the URLs in WCS6 has been replaced by <wcf:url>. So, let us spend some time leaning about the tag. 


About the wcf:url tag
The wcf:url tag builds a URL and applies the appropriate WebSphere Commerce supported rewriting rules.
It contains the following additions compared to the c:url tag:
  • It builds a full path URL, rather than a relative path.
  • It builds SEO compliant URLs if the feature is used in WebSphere Commerce.
  • It adds a prefix to the URL with the appropriate protocol, HTTP or HTTPS, depending on the Struts configuration files.
To know more about the tag and its parameters , please refer Infocenter

Important Note for FEP3 and above

Both the new Feature Pack 3 and previous SEO implementations are supported. You can choose which SEO solution to use by updating wc-server.xml.


<SEOConfiguration enable="true" dynamicUrl="true" defaultUrl="www.madisons.com">
     <context-root-rewrite value="/shop"/>
     <mapper-class-name value="com.ibm.commerce.seo.url.helpers.SEOURLMapperImpl"/>
</SEOConfiguration>
 
Either value or patternName is required. If workspace is used, then both value and patternName are required. If the value parameter is provided, then URLs will be constructed based on the mapping found in SEOUrlMapper.xml file using the SEO implementation from WebSphere Commerce Version 7 to Version 7 Feature Pack 2. If patternName is provided and SEO is enabled in wc-server.xml as shown in the following example, then URLs will be constructed based on the Version 7 Feature Pack 3 SEO design, using the pattern template definitions. Preference will be given to the patternName attribute over the value attribute.

If URL construction using patternName
fails (due to an invalid patternName or a missing parameter), dynamic
URL's will be constructed if the dynamicUrl attribute is set to true.
If dynamicUrl is set to false, then wcf:url tag returns defaultUrl
specified in wc-server.xml 
The URL creation order is:
  1. If SEO Enabled and patternName specified, use patternName and construct new SEO URL
    1. If new SEO URL construction fails and dynamicUrl = true, a dynamic URL is constructed
    2. If dynamicUrl = false, a defaultUrl is constructed
  2. Otherwise the value attribute is used an old SEO URL is constructed
The following diagram helps understand the SEO URL differences and the tag parameters :

Example
The following example forms a URL to display the shopping cart using the <wcf:url> tag. It specifies the URL type as an AJAX call.
<wcf:url var="currentShoppingCartLink" value="ShopCartPageView" type="Ajax">
   <wcf:param name="storeId"   value="${WCParam.storeId}"  />
   <wcf:param name="catalogId" value="${WCParam.catalogId}"/>
   <wcf:param name="langId" value="${WCParam.langId}" />
</wcf:url>
 
Related Blogpost
Smarter SEO for Smarter Commerce