Saturday, July 20, 2013

ATP inventory concepts | Order Management System!!


This blog does not give any coding example but folks working on WCS implementations, who work on Inventory and ATP and It is one of the most important concepts of an eCommerce site. Managing supply and demand and making sure the inventory is correctly updated on order placement is very important for running any business.

Important Inventory and ATP terminology and concepts: These are high level concepts and I am sure back-end systems such as SAP, Oracle, Sterling order management systems use these terms and each one of them could have slight variants.

  • Supply is all the inventory available.
  • Demand is all the orders placed and not yet fulfilled.--Reservations/Allocated Orders/Future expected demand.
  • Supply Type or Inventory buckets, this is gives a clear picture of Inventory availability and it could be moved between multiple buckets such (QA hold or Intransit or) . This is very important in calculating available inventory for consumption.
  • Demand Type is the group of quantities committed across various commitment channels.
  • Demand Supply Matching: This is also called available to sell calculation, Supply with a sufficient lifespan     along with demand.
  • Simple example of Available to Sell calculation
      • (Sum of All checked supply types) – (sum of all corresponding demand type)
      • Available To Sell = (Onhand + Intransit +  Qty in PO) – (Open Order + Reserved + Allocated)
  • Availability on hand, back order, preorder (Future Inventory).
  • Managing inventory at the plant level or distribution level.
  • Available-to-promise (ATP) enables to decide the availability of a item for current and future demand. (simplest version is supply-demand is ATP)
  • Based on threshold and Inventory availability -- Availability high\low\future inventory.
  • Inventory sourcing at the plant level or pool level.
  • Order fulfillment process, there are multiple demand types -Open/Reserved/Scheduled/Allocated.
  • ATP Monitor versus Inventory Monitor.
  • ATP Monitoring  modes:
    • Activity Based: Raises an event in real time every time an item goes      above or below one of the thresholds.
    • Quick Sync: Re-sends the most recently published inventory availability information.
    • Full Sync: Monitors all of the items regardless of activity and publishes the inventory information for all of the items.


ResolveParameter class, an Important commerce tool !!

ResolveParameter is a very important class when implementing custom code in commerce and I am sure, it is a very important tool for commerce developers doing custom implementations. When a custom implementation requires to post multiple name/value pairs of the same type, this class is really useful.
e.g. URL params
catentryId_12343=value1,catentryId_22343=value2,catentryId_32343=value3
orderItemStatus_10000=value10001,orderitemsStatus_10004=value

//resolve params in request properties, returns the hashtable of name, value pairs.
public void setRequestProperties(TypedProperty reqProperties) throws ECException {
ihshCatentry_id  = ResolveParameter.resolveValues(OrderConstants.EC_CATENTRY_ID,  requestProperties, false);
}


Couple of other methods from ResolveParameter that I find useful from time to time.

/*
* returns the order item status from the hash table using the resolve parameter method.
*/
protected String getOrderItemStatus(Integer i, Hashtable hashOrderItemStatus )
  throws InvalidParameterValueException
{
String methodName = "getOrderItemStatus";
  String orderItemStatus;
  try
  {
  orderItemStatus = ResolveParameter.getString(i, hashOrderItemStatus);
  } catch (NumberFormatException ex) {
    throw new InvalidParameterValueException("orderItemId",
      ex.getMessage());
  }
  return orderItemStatus;
}    
/*
* returns the order item item id from the hash table using the resolve parameter method.
*/
protected Long getOrderItemId(Integer i, Hashtable hashOrderitemId )
  throws InvalidParameterValueException
{

  Long orderItemId;
  try
  {
    orderItemId = ResolveParameter.getLong(i, hashOrderitemId);
  } catch (NumberFormatException ex) {
    throw new InvalidParameterValueException("orderItemId",
      ex.getMessage());
  }
  return orderItemId;
}  

Thursday, June 6, 2013

Sales Catalog ---SOLR

I received a question regarding SOLR setup for sales catalog. This blog provides a quick write up on the question and the tools provided out of the box. SOLR is totally based on master catalog and locale (en_US, fr_CA..etc) and it does not need any configuration for different sales catalogs for a single store or multiple stores.
Solr document is created during indexing and it's configured in wc-data-config.xml, there's a bunch of sqls in there and schema.xml defines all the fields in the 'document'. All the store relationships are updated as a part of those out of the box SQL's to the document.

There are a few utilities provided out of the box. setupSearchIndex takes master catalogId and languageId
that sets up the WCDE_ENT70/search/pre-processConfig  and WCDE_ENT70/search/solr/
when running on the server, you'll probably want to use the "-remote true" option.

Once the index is setup, the next step is to  run preprocess, use di-preprocess and to re-index, use di-buildindex

PreProcessing step is to flatten data and buildIndex is used to building the search index.

Explanation of document from InfoCenter:
Solr maintains one or more indexes, which are searchable collections of items called documents. When using Solr to support catalog search, the documents in the index represent catalog entries.
Adding a document to an index is often referred to as indexing the document.
Each document is composed of a set of attributes called fields. For example, a catalog entry document can have fields such as Partnumber, Name, and Description.
When a document is added to an index, each field in the document can be indexed or stored, or indexed and stored. An indexed field is one that can be used for searching, sorting, and faceting. If the field is indexed, document IDs can be determined from field values. A stored field is one where its value can be retrieved by a search. Alternatively, if the field is stored, field values can be determined from document IDs.

Reference: definition of document:
http://pic.dhe.ibm.com/infocenter/wchelp/v7r0m0/topic/com.ibm.commerce.developer.doc/concepts/csdsearchindex.htm

Saturday, April 20, 2013

ByPassHttpAdapter | XML post to commerce URL

This is a very useful extension when you need to build an extension where if SOAP is not accepted and authToken based authentication is not an option for inbound request.
if you want an external site to post XML into commerce. This would be a good approach.

Sample code and wc-server.xml

public class BypassHttpProgramAdapterImpl extends HttpProgramAdapterImpl implements
HttpAdapter, HttpAdapterFactory {

/*override the method to return a null if bypass condition is true, you can add bypass condition as a custom XML element in wc-server.xml*/
public HttpAdapter createAdapter(HttpServletRequest request, HttpServletResponse  response, TypedProperty param ) {
    //check for extension code.
}


}

<HttpAdapter
      deviceFormatId="-10000"
      deviceFormatType="XmlHttp"
      deviceFormatTypeId="-10000"
      enabled="true"
      factoryClassname="com.custom.programadapter.XXBypassHttpProgramAdapterImpl" name="XML/HTTP">
      <ProgramAdapter>
        <SessionContext ....
          <SessionContextConfig/>
        </SessionContext>
        <Configuration
          supportedCharacterEncoding="ISO8859-1, UTF-8, utf-8"
          supportedContentTypes="text/xml, text/xml; charset=UTF-8, text/xml-SOAP, text/xml; charset=utf-8"
          supportedMessageMappers="WCS.SOAPINTEGRATION, WCS.INTEGRATION" supportedMethods="POST, M-POST"/>
      </ProgramAdapter>
    </HttpAdapter>

Thursday, April 11, 2013

Pros and Cons of Ajax

Ajax Simplified: I have been meaning to put this together, even for my own understanding and pros and cons and the SEO impact of using Ajax.

Pros:
1. Ajax does a great job of not fully loading the page, so refresh smaller areas/faster
2. A lot of fancy things auto complete\Edit in place\ratings\RSS reader and also sorts of gimmicks.
3. On refresh, it does not trigger a HTTP Post as opposed to traditional web apps.
4. Simpler actions makes the over all site faster, things like e.g. Facebook like

Cons:
1. SEO suffers as most crawlers are links based and have limited JS support so if you use fewer URL's to do a lot of actions, this is bad for SEO visibility of the site.
2. User experience, can not navigate to the path on refresh, so this could be bad user experience, if the Ajax is heavily used and you navigate to 3-4 levels and if you need to go back or forward.

Good Example of Ajax implemented site with SEO friendly URLs:  https://github.com/
As you would see here with github, even though it is Ajax, the links are changing which is kind of best of both worlds: https://github.com/karmi/tire
Limitation of the above approach: Only HTML5 supports this feature--History supported browsers (most modern browsers). Push the URL to the browsers and ajax takes care of all the handling.You need to implement If\Else for older browsers and fortunately there is an API available, please find below link

https://github.com/browserstate/history.js

Top 10 Ajax applications in commerce (WCS):  I will fill this soon.

Sunday, March 10, 2013

Transaction timeout error | Long running feeds| New transaction

If you had to run feeds that would take longer than appserver transaction timeout or any process that runs for ever and if you have see the transaction timeout exception as below for any long running processes

0ddf0003a SystemErr     R Caused by: org.omg.CORBA.TRANSACTION_ROLLEDBACK: javax.transaction.TransactionRolledbackException:  ; nested exception is:
      javax.transaction.TransactionRolledbackException: Transaction is ended due to timeout  vmcid: 0x0  minor code: 0  completed: No
0ddf0003a SystemErr     R    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
0ddf0003a SystemErr     R    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)


I would not advise this code solution for all scenarios and only after considering all scenarios, If you need to add code to create new transaction and manage your transactions. Find below code example.


Solution: Using new transaction in your code.

int transactionSize=5000; //example transaction size

try{
for (int recordCount=0; recordCount <= recordsFromDB.length; recordCount++)
    TransactionManager.begin();

    //do business logic
    if ( (transactionSize != null) && (recordCount%transactionSize.longValue() == 0) ) {
                TransactionManager.commit();              
    } 

catch (Exception e) {
                TransactionManager.rollback();
                logging(METHOD_NAME, "Exception at performExecute" + e.getMessage());
 }
           
   

Friday, February 8, 2013

Facebook meta tags using commerce JSP

This post goes through an example from commerce JSP to generate, FaceBook meta tags. The code snippet below prints the meta tags for 2 different kinds of commerce product types, Items and Packages. Based on the type of the product, a different commerce data bean is selected.