Thursday, April 23, 2015

Existing Mediator used in Dataload Utility

Existing Mediator used in Dataload Utility


If you wanted to use the WebSphere Commerce Dataload utility, it expects the input source as CSV or XML file. If your Datasource is neither of these, then you need to write custom data reader for reading the source and mediators for pushing the data to WCS tables.

If your target tables are standard Catalog tables, then you can use OOB mediators itself and no need to write explicit mediators. Here are the common mediators, which are used as part of Catalog dataload,

Type: Catalog Groups
OOB Mediator : com.ibm.commerce.catalog.dataload.mediator.CatalogGroupMediator
Tables Affected :
   CATGROUP
   SEOURL
   SEOPAGEDEF
   STORECGRP
   CATGRPDESC
   CATTOGRP
   CATGRPREL
   CATGPCALCD

Type : Attribute Dictionary
OOB Mediator : com.ibm.commerce.catalog.dataload.mediator.AttributeDictionaryAttributeMediator
Tables Affected :
   ATTR
   ATTRDESC
   SRCHATTR
   SRCHATTRPROP
   ATTRDICTSRCHCONF
   FACET

Type : Catalog Entries
OOB Mediator : com.ibm.commerce.catalog.dataload.mediator.CatalogEntryMediator
Tables Affected :
   SEO
   BASEITEM
   BASEITMDSC
   STOREITEM
   ITEMVERSN
   DISTARRANG
   VERSIONSPC
   STORECENT
   CATENTDESC
   CATGPENREL
   LISTPRICE
   CATENTSHIP
   CATENTSUBS
   CATENCALCD
 
Type: Catalog Entry Attribute Dictionary Attributes
OOB Mediator : com.ibm.commerce.catalog.dataload.mediator.CatalogEntryAttributeDictionaryAttributeMediator
Tables Affected:
   ATTRDICT
   ATTRVAL
   ATTRVALDESC
   CATENTRYATTR

Type: Catalog Entry Merchandising Associations
OOB Mediator :com.ibm.commerce.catalog.dataload.mediator.CatalogEntryAssociationMediator
Tables Affected :
   MASSOCCECE

Type : Attachment Assets
OOB Mediator :  com.ibm.commerce.content.dataload.mediator.AttachmentMediator
Tables Affected :
   ATCHTGT
   ATCHTGTDSC
   ATCHAST
   ATCHASTLG

Type : Offer & Offer Prices
OOB Mediator : com.ibm.commerce.price.dataload.mediator.OfferMediator
Tables Affected :
    OFFER
    OFFERDESC
    OFFERPRICE

SOI To Controller Command mapping


Creating Refresh Area in V7

Creating Refresh Area in Websphere Commerce with Dojo

Refresh Areas are created when you need to refresh with new content when users interact with the user interface.
For this case, it is necessary to use the render context, refresh area and refresh controllers API from the WebSphere Commerce AJAX framework.
Follow a step-by-step in how to create a refresh area.
1.) Identify the fragment you want to refresh
2.) Create an action and a forward in struts-config-ext.xml
<forward className=”com.ibm.commerce.struts.ECActionForward” name=”ShipServiceMethodsDisplayView/10101″ path=”/ShoppingArea/CheckoutSection/SingleShipment/SingleShipmentShippingMethodDetails.jsp”/>
<action path=”/ShipServiceMethodsDisplayView” type=”com.ibm.commerce.action.ExtendedBaseAction”/>
3.) Create the Access Control Policies and Run in your environment or you can just insert into your database as well:
insert into acaction ( acaction_id, action) values ( (select min(acaction_id) – 1 from acaction), ‘ShipServiceMethodsDisplayView’);
insert into acactactgp (acaction_id, acactgrp_id) values ( (select acaction_id from acaction where action = ‘ShipServiceMethodsDisplayView’), (select acactgrp_id from acactgrp where groupname = ‘AllSiteUsersViews’) );
4.) Define in a .js file the context. The context will handle and allow to refresh the area
wc.render.declareContext(“shippingServiceAllAreaContext”,{orderId:”",addressId:”"},”");
5.) Declare the controler. This allow to refresh the context
wc.render.declareRefreshController({
id: “shippingServiceAllAreaController”,
renderContext: wc.render.getContextById(“shippingServiceAllAreaContext”),
url: “ShipServiceMethodsDisplayView”,
formId: “”
,modelChangedHandler: function(message, widget) {
var controller = this;
var renderContext = this.renderContext;
widget.refresh(renderContext.properties);
}
,renderContextChangedHandler: function(message, widget) {
var controller = this;
var renderContext = this.renderContext;
widget.refresh(renderContext.properties);
}
,postRefreshHandler: function(widget) {
var controller = this;
var renderContext = this.renderContext;
cursor_clear();
}
6.) Now, add the refresh area widget where the jsp is include
<div dojoType=”wc.widget.RefreshArea” widgetId=”shippingServiceAllArea”  controllerId=”shippingServiceAllAreaController” id=”shippingServiceAllArea”>
<%out.flush();%>
    <c:import url=”/${sdb.jspStoreDir}/ShoppingArea/CheckoutSection/SingleShipment/SingleShipmentShippingMethodDetails.jsp”>
        <c:param value=”${currentOrderId}” name=”orderId”/>
    </c:import>
<%out.flush();%>
</div>
<script type=”text/javascript”>
    dojo.addOnLoad(function() {
        parseWidget(“shippingServiceAllArea”);
    });
</script>
* Do not forget to add parseWidget with the refreshArea widget id.
7.) Now you must identify when to call the refresh controller and update the context according with your process
wc.render.getRefreshControllerById(‘shippingServiceAllAreaController’);
wc.render.updateContext(‘shippingServiceAllAreaContext’,{orderId:thisOrderId ,address:thisAddressId});

Email Configuration

Email Configuration
First we have to make an entry in MSGTYPES table in our database.
In MSGTYPES table we have to enter
For example:
Name – SendEmail (Name of the new Mesgtype)
ViewName – SendEmailView (Name of the View for sending EMAIL)
Description – SendEmail
Once the table entry is done then logon to ADMIN console of WCS.
Click on Configuration  Transports


Click on Email link










SMTP Configuration










To configure Message type to send EMAIL: To configuration >> Message Types










Create New Message Type:
Message Type : You will select the message type from drop down, check for name which you have entered in Database in first step: (here SendEmail)
Transport : Will be EMAIL
Device Format : Standard Device Format
>>>>> Click on Next >>>>>>
After this configuration from Admin Console then we will write code to send the mail to particular user.
  • Register the View (here SendEmailView)
<forward name="SendEmailView/0/-3" path="/MyNewView.jsp" className="com.ibm.commerce.struts.ECActionForward">
<set-property property="resourceClassName" value="com.ibm.commerce.command.HttpForwardViewCommandImpl"/>
<set-property property="interfaceName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommand"/>
<set-property property="implClassName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl"/>
<set-property property="direct" value="true"/>
</forward>
<action path="/SendEmailView" type="com.ibm.commerce.struts.BaseAction">


Code to be placed in java
==================================================================================
String strMethodName = "SendEmail";
SendMsgCmd cmdSendMsg = (SendMsgCmd)CommandFactory.createCommand("com.ibm.commerce.messaging.commands.SendMsgCmd", getStoreId());

cmdSendMsg.setMsgType("SendEmail"); // Get the details of Registered Message Type
cmdSendMsg.setCommandContext(getCommandContext()); // set the command context
cmdSendMsg.setStoreID(commandContext.getStoreId());
cmdSendMsg.setConfigData("sender","harpreetsinghdelhi@gmail.com"); // Sender’s Email
cmdSendMsg.setConfigData("recipient","harpreetsinghdelhi@gmail.com"); //receiver’s Email
cmdSendMsg.setConfigData("subject","Test Mail"); // Subject Name

cmdSendMsg.compose(null,getCommandContext(),getRequestProperties()); // composing Mail
cmdSendMsg.sendImmediate(); // Executing Mail

If we want to send some dynamic values to a JSP, we can achieve by using Typed Properties.
WE can place all the properties using Typedproperty class, and then we can fetch all those properties in a JSP which we have registered against the Message Type.
We can send the Typed properties or else we can also send the whole request object also while composing

cmdSendMsg.compose(null,getCommandContext(),TypedPropertyObj); // composing Mail






WCS Order management flow

WCS Order management flow
Place an order.
  • A customer(use store front) or an administrator(Use accelerator/MC) who has the authority to act on behalf of the customer places an order with the store.
  • While adding items to shopping cart order status will be Pending state
Check out:
  • After the shopper completes the order checkout sequence, the order moves from a Pending state (P) to M state (pending payment approval). Here the order can also go into the state of M or C (for some payment method) or L (no inventory and no back order) or B (some backordered orderitems).
  •  When the order checkout sequence is complete the order moves to one of the following states:
    •  A:Payment authorization requires review
    •  B:Backordered
    •  C:Payment authorization complete
Order Approval
  • B2B required Order Approval , B2C not required
  • Approve payment for the order, if required. Payment methods such as COD (Cash on Delivery) and Bill Me do not need approval.
Order Process
  • If the order contains products that are to be backordered, then it moves to state B (backordered).
  • Orders can be backordered with the command ProcessBackorders, or by a scheduler.
  • For reauthorization, the order goes back to state M or a state such as A, I, B, or C. After a backorder is approved, it should be allocated and not reordered, or else it may go back for approval again.
  • Order process includes following task -using accelerator
    • Finding Order
    • Change the quantity of the product in the order
    • Changing the purchase order number for an order in a B2B direct store
    • Add/Remove a product to an order
    • Selecting another shipping address/Shipping method/billing address for an order
    • Changing the total price of an order
    • Editing an order level adjustment
    • Changing the payment options/payment processing for an order
    • Add comments
    • View -Order summary/payment status/Order invoice
    • Cancel the orders
    • Apply Order Blocks
Order Release:
  • Release the order to fulfillment. The Scheduler Job ReleaseToFulfillment releases the orders to fulfillment.
  • When all order items for the order are released, the order moves to state R (Released).
Order Fullfillment:
  • Create a pick batch for all orders released to the specified fulfillment center using Websphere commerce Accelerator
  • View and print pick tickets.
  • View and print packaging slips.
  • Pick and pack products specified in the pick ticket and packing slip.
  • Create package.
  • Ship goods. Ship the order to the customer. (No action from wcs)
Order Completion:
  • Confirm shipment has been sent. When all order items are shipped, the order moves to S (Shipped) status.
  • Finalize the order.
    • The BalancePayment scheduled job initiates payment deposit. The order state moves to D (Deposited).
    • The OrderClose checks whether the shipped order is totally deposited. If YES, the order status is changed to 'D';
    • OrderPaymentSynchronize:Checks whether the order is totally authorized. If YES, the order status is changed to 'C'


Some Order Command tips:

OrderItemAddCmdImpl
  -Call ResolveSKUCmdImpl
  -check catentry is buyable or not
  -Check customer is entitlement to buy this catentry id
  -if all above params correct contine
  -if fails but continue=1 then skip to next order
  -if orderitemId provided update the
  -if partnum/catentry provided new orderitem id
  -if address_id not specified use default(P,nickname)
  -if quantity is 0 delete
  -if shipmodid not availabnle use default
  -Call GetContractUnitPriceCmd to calcuate the price
-OrderItemUpdateCmdImpl
-OrderCreateCmdImpl
-UpdateShippingAddressCmd
-ValidateTradingPaymentCmd
-DoInventoryActionCmd
-UpdateShipInfoCmdImpl
-RaiseOrderEventCmdImpl
 OrderCalculateCmdImpl
This command is called by OrderItemBaseCmdImpl and OrderItemDeleteCmdImpl to refresh the order price, charges and freebie items after Add, Update and Delete order item.
The default implementation of this command is OrderCalculateCmdImpl. But in out-of-the-box CMDREG table, the implementation of this command is mapped to PromotionEngineOrderCalculateCmdImp

-Unlock the order
-initialize the specified CalculationUsages that are enabled
-if RulesBasedDiscount component is enabled
-call discount service to obtain the list of catalogentry to add to order
-if ATP is disabled and there is insufficient inventory
-remove catalogentry from the list
-add catalogentry identifier to outOfInventoryCatalogEntryId list
-Recalculate specified calculation usages
-call the OrderItemAdd
-update the productTotal attributes of the Order and its OrderItems
-update the SubOrders for the Order
-apply the specified CalculationUsages that are enabled
-summarize the specified CalculationUsages that are enabled
-Finally, call the setResponseProperties() method.
-ResolveOrderCmd
-Promotion engine to determine the catalog entries to add
-Recalculate Order
 OrderPrepareCmdImpl
  -prepare order by
  -determine prices
  -discounts
  -shipping charges
  -shipping adjustment
  -taxes
  -Lock the order(1)
  -ensure all orderitems are buyable
  -update order item address
  -update order item validation
  -update order item prices
  -update order item total
  -update auto added order items
  -check order inventory
 
OrderProcessCmdImpl

 OrderPrepareCmdImpl
  -Prepares the orders for Display(OrderDisplayCmd)
  -Prepares the orders for OrderProcess
  -if no orderId then use Current pending order
  -Default error view OrderNoneErrorView
  -if commit=1 start new db transaction for every order
  -status should P WINE (bipins formula :)
  -Call PrepareOrder task command
  --Delete generated orderitems(PREPAREFLAG)
  --check CATENTRY.BUYABLE=1
  --If ATP inventory allocation is enabled/disabled, call the DoInventoryActionCmd
  --Call the ValidateDynamicKitConfiguration task command.
  --Obtain new unit price(GetContractSpecialPrice/GetBaseSpecialPrice)
  --Do not refresh prices for order items whose prepareFlags attributes specify "quotation
  -prepare order by
  -determine prices
  -discounts
  -shipping charges
  -shipping adjustment
  -taxes
  -lock the order
  -ensure all orderitems are buyable
  -update order item address
  -update order item validation
  -update order item prices
  -update order item total
  -update auto added order items
  -check order inventory

Monday, December 1, 2014

WC not getting publish...

Cause
A previous failed application update has corrupted the applications configuration information.
 Resolving the problem
Perform the following steps to resolve this issue:

1. Stop the server

2. Backup and remove the following directories:
- WCDE_installdir/wasprofile/config/cells/localhost/cus
- WCDE_installdir/wasprofile/config/cells/localhost/blas
- WCDE_installdir/wasprofile/wstemp
- WCDE_installdir/wasprofile/temp
- WCDE_installdir/wasprofile/config/temp
3. Start the server

4. Publish the WebSphere Commerce application.

The above steps clears corrupted server configurations and allows for the publish action to run properly.

Important Note

It is important that you keep a backup of the directories listed above since you may run into issues like few applications such as WAS Admin Console may not be accessible. If you face the same issue, please refer to the steps provided in my post - RESOLVED : Unable to access WAS Admin Console

Alternatively , try just removing the module which is causing problem during publishing - WC

Determining Application Server you are on in Firefox



Determining Application Server you are on in Firefox
1.       Tools -> Options
2.       Click Privacy
3.       Click Show Cookies
4.       Find Nashbar or Performance. (If you type in N or P, it will narrow it so that you can find them)
5.       Find the JSESSIONID Cookie
6.       Select it.
7.       The JSESSIONID should end with :13rdkhjun or : 143c5mheu or :13rdirq71
a.       143c5mheu - .25 (Server3)
b.      13rdirq71 - .13(Server1)
c.       13rdkhjun - .15(Server2)
8.       Based on the ID you know which server you are on.

Changing which Appserver you are on
1.       First start by going into Firefox and going to the following URL to get Add-on for editing the cookie. (https://addons.mozilla.org/en-US/firefox/addon/4510/)
2.       Follow all directions for installing the addon.
3.       Once the addon is installed go to site you want to work with.
4.       Click Tools -> Cookie Editor
5.       You can filter the cookies by typing in Performance or Nashbar
6.       Select Cookie Name JSESSIONID
7.       Click Edit
8.       Change what is after the : to match the application server you want to try.
9.       Click Close refresh the page.
10.   You are now working on that server.