Thursday, October 10, 2013

Tax customizations to update tax from third party !!

While customizing tax integration with third party, it is important to understand the end points provided by commerce to customize.
Please find below out of box commerce tables and commands that needs to be customized.


INSERT INTO CALMETHOD (CALMETHOD_ID, STOREENT_ID, CALUSAGE_ID, TASKNAME, 
DESCRIPTION, SUBCLASS, NAME) VALUES ((select coalesce((min(calmethod_id)-1),1)
from calmethod), 10701 , -3,'com.custom.commerce.order.calculation.ApplyCalculationUsageCmd', 'custommethod for calculation sales taxes', 12, 'ApplyCalculationUsageSalesTax')

update stencalusg SET CALMETHOD_ID_APP = 
(SELECT CALMETHOD_ID FROM CALMETHOD WHERE TASKNAME = 'com. custom .commerce.order.calculation.ApplyCalculationUsageCmd'
AND STOREENT_ID = 10701 AND CALUSAGE_ID = -3) and calusage_id=-3

insert into CMDREG (STOREENT_ID, INTERFACENAME, DESCRIPTION, CLASSNAME, PROPERTIES, LASTUPDATE, TARGET) values 
(0,'com.custom.commerce.order.calculation.ApplyCalculationUsageCmd','Sales Tax calculation usage for third-party tax 
providers','com.custom.commerce.order.calculation.ApplyCalculationUsageSalesTaxCmdImpl',null,null,'Local')

//out of the box command required to be extended.
public class ApplyCalculationUsageSalesTaxCmdImpl extends ApplyCalculationUsageCmdImpl implements com.custom.commerce.order.calculation.ApplyCalculationUsageCmd{

    public static final String CLASSNAME = ApplyCalculationUsageSalesTaxCmdImpl.class.getName();

    private static Logger LOGGER = Logger.getLogger(CLASSNAME);

   public void performExecute()

    throws ECException
   {
       String methodName = "performExecute";
       if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
           LOGGER.entering(CLASSNAME, methodName);
       }
    
     //get tax from Third party
       BigDecimal orderTax = new BigDecimal(100.00);
       
       Item[] items = super.getItems();
       // set on first order item
       for (int i = 0; i < 1; i++) {
            items[i].setSalesTaxTotal(orderTax);
            items[i].commit();
       }
       if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
           LOGGER.exiting(CLASSNAME, methodName);
       }
   }   


Wednesday, October 9, 2013

Creating Assets in management center and displaying in front end.


Steps in CMC:
1. Go to Assets menu and select the appropriate stores.
2. Create a file, make sure to give a exten (.pdf, jpg), even in the name.
3. Go to Attachment selection inside Asset Menu, Create a attachment, the name given in attachment, can be used in the front end for links.
4. Go to Catalog menu and select a store and create a category inside master catalog categories and reference the attachments created in step 3.

Extended CategoryDataBean:
public void populate() throws Exception{
Enumeration categoriesEnum=CatalogGroupCache.findByIdentifierAndStore(this.getCatIdentifier(),this.getCommandContext().getStoreId());
if (categoriesEnum.hasMoreElements()) {
CachedCatalogGroupAccessBean cgpCached= (CachedCatalogGroupAccessBean) categoriesEnum.nextElement();
catGroupId=cgpCached.getCatalogGroupReferenceNumber();
}
super.setCategoryId(catGroupId);
super.populate(); }

JSP Code:

<wcbase:useBean id="documentsCategory" classname="com.custom.commerce.catalog.beans.EXTCategoryDataBean" >
<c:set property="catIdentifier" value="documents" target="${documentsCategory}" />
</wcbase:useBean>

<c:set var="allAttachemnts" value="${mediaDownloadsCategory.allAttachments}" />
<c:if test="${!empty allAttachemnts}">
<c:forEach items="${allAttachemnts}" var="attachmentDB" varStatus="status">
<c:forEach items="${attachmentDB.attachmentAssets}" var="attachmentAssets" varStatus="status">
<c:if test="${fn:indexOf(attachmentAssets.attachmentAssetPath,'PDF_') > 0 }">
<a href="${hostPath}${attachmentAssets.objectPath}${attachmentAssets.attachmentAssetPath}"><c:out value="${attachmentDB.fileName}"/></a>
</c:if>
<c:if test="${fn:indexOf(attachmentAssets.attachmentAssetPath,'DOCUMENT_') > 0 }">
<div class="image"><img border="0" src="${hostPath}${attachmentAssets.objectPath}${attachmentAssets.attachmentAssetPath}"/></div>
</c:if>
</c:forEach>
</br>
</c:forEach>
</c:if>


Content Assets upload settings in wc-server.xml: Can change the number of files and the interval.

<ManagedFileUpdateEARConfiguration display="false">
        <ContentManagedFileEARUpdate Implementation="com.ibm.commerce.filepublish.util.ContentManagedFileEARUpdateImpl"/>
        <ContentManagedFileHandler Implementation="com.ibm.commerce.filepublish.util.ContentManagedFileHandlerImpl"/>
        <ProductionServerInformation applicationName="WC_demo"/>
        <ModuleInformation moduleName="Stores.war"/>
        <EvaluationCriteria minNumOfFilesForUpdate="4" minSecFromLastUpload="300"/>
    </ManagedFileUpdateEARConfiguration>


CoreMetrics | basics !!

Coremetrics provides web analytics and the other big competitor in this space is Omniture. The analytics integration is provided using Javascript. In Websphere commerce there is a tighter integration in the form of tags that are provided out of the box and  coremetrics reports are provided in management center in newer versions of WCS and older versions still need to use coremetrics site to view reports.

  1. Create a coremetrics account.
  2. Update WC\xml\config\bi\biConfig.xml with correct configuration for coremetrics configuration. clientId is the contract ID is usually one for test environments and 1 for production and ssoKey is generated from Coremetrics support.
  3. Configuration in wc-server.xml 
    • <configuration
                    cmClientID=""
                    password=""
                    serviceURL="https://wscreceiver.coremetrics.com/Receiver/sendEventData"
                    sslKeyPassphrase="WebAS"
                    sslKeyStore="/usr/WebSphere/AppServer/profiles/demo/etc/DummyServerKeyFile.jks"
                    sslTrustPassphrase="WebAS"
                    sslTrustStore="/usr/WebSphere/AppServer/profiles/demo/etc/DummyServerTrustFile.jks"
                    transmitClassName="com.ibm.commerce.bi.events.transmit.CMWebServiceTransmitter"
                    transmitEnabled="false" username=""/&gt
  4. Access Coremetrics reports
    • Open a Web browser to the following URL: https://welcome.coremetrics.com
    • Log in using your Client ID, username, and password. 
    • Starting V7, Feature Pack 3. We can also view reports directly from Management Center using links in the Catalogs, Marketing and Promotions tool.
    There are several tags for CoreMetrics, one example is pageView and most commonly used is cm

    Include the tag library in the pages
    <%@ taglib uri="http://commerce.ibm.com/coremetrics"  prefix="cm" %>

    PageView Tag: Most commonly used tag to track pages.

        <flow:ifEnabled feature="Analytics">
            <c:choose>
                <c:when test="${isCSR}">
                    <cm:pageview pagename="${storeCountryCode}:SEARCH PAGE" extraparms="YES" />
                </c:when>
                <c:otherwise>
                    <cm:pageview pagename="${storeCountryCode}:
    SEARCH PAGE" extraparms="NO" />
                </c:otherwise>
            </c:choose>
        </flow:ifEnabled>


    Conversion tag: For Ajax calls

    <cm:conversion eventId="${WCParam.eventId}" category="WISHLIST" actionType="2" points="10" returnAsJSON="true"/>

    campurl Tag: Mostly for static pages

                                  <cm:campurl espotData="${marketingSpotDatas}" id="clickInfoCommand" url="${clickInfoURLForAnalytics}" 

    References: More tags
    http://pic.dhe.ibm.com/infocenter/wchelp/v7r0m0/topic/com.ibm.commerce.Coremetrics.doc/refs/rmttagsinstorejsps.htm
    Web 2.0 integration:
    http://pic.dhe.ibm.com/infocenter/wchelp/v7r0m0/topic/com.ibm.commerce.Coremetrics.doc/concepts/cmtweb20intro.htm