Wednesday, December 31, 2014

Server side log configuration in IBM WCS

1.       Log Levels:
a.       To change the log level, go to the Server and right click on the Test Server and start the Admin Console.
b.      Go to the Server in the following path.
                                                               i.     


                                                             ii.     

                                                            iii.     



                                                           iv.     
                                                             v.     


                                                           vi.     

                                                          vii.     



Friday, December 5, 2014

The socket bind failed for host * and port 80

The socket bind failed for host * and port 80
Problem :
TCPPort       E   TCPC0003E: TCP Channel TCP_2 initialization failed.  The socket bind failed for host * and port 80.  The port may already be in use.

Resolution : You can stop the HTTP service temporarily from the command line:
From command prompt "run" : net stop HTTP
After running this command it will show dependent services and ask -- Do you want to continue this operation? (Y/N) [N]: Y
At last it will say : The HTTP service was stopped successfully.
Now In console you will not get this problem.


Another Approch :

When attempting to access the home page for one of the WebSphere Commerce starter stores (for example, ConsumerDirect), an error message displays. An example of the error message follows:
A WebGroup/Virtual Host to handle /webapp/wcs/stores/servlet/ConsumerDirect/index.jsp has not been defined.
The virtual host definitions in the WebSphere Application Server might not be functioning properly.
A simple test to verify this situation is to attempt to access the starter store's home page using port 8000 instead of port 80. For example if ConsumerDirect was published, try to access the store using https://localhost:8000/webapp/wcs/stores/servlet/ConsumerDirect/index.jsp. If port 8000 was successful then the virtual host definitions will need to be updated.
To change the virtual host definitions:
  1. Start the WebSphere Commerce Test Server using either the Rational Application Developer interface or using the startWCServer.bat script.
  2. Access the WebSphere Application Server's administrative console
  3. Select Environment > Virtual Hosts
  4. Select the default_host entry
  5. From the "additional properties" section select "Host Aliases"
  6. Delete the references to port 80 and 443
  7. Save your change to the master configuration.
  8. Restart the server.
You should now be able to access the starter stores using port 80.

Thursday, November 27, 2014

Creating custom widget in IBM WCS


 
Widgets are the interchangeable building blocks that a Management Center user can use to compose layouts for store pages. Widgets are independent user interface modules that retrieve and display a specific type of data on a store page.
Generating Commerce Composer widget source code
 Create a temporary project in your WebSphere Commerce Developer workspace. This project is used as the target location where the Java Emitter Template (JET) Transformation generates the source code files for creating your widget.
a.Right-click within the Enterprise Explorer view. Select New > Project.
b.In the New Project wizard, expand General. Select Project. Click Next.
c.For the Project name field, enter a name for the temporary project. For example, NewWidgetProject.
d.Click Finish.
In temporary NewWidgetProject project, create an XML file to use as a pattern input file for the JET Transformation.
1.Right-click the temporary NewWidgetProject project. Select New > File.
2.In the New File wizard, ensure that your temporary project is selected as the parent folder. Enter a File name for the pattern input XML file. For example, NewWidgetPatternInputFile.xml.
3.Click Finish.
<pageLayout vendor="myCompany" targetFolder="NewWidgetProject">
  <widget>
    <widgetDef identifier="myNewContentRecommendationWidget" 
     UIObjectName="myNewContentRecommendationWidgetObject"
     displayName="My New Content Recommendation Widget"
     description="This widget displays marketing content, such as ads, on a store page"
     widgetDisplayGroups="AnyPage,SearchPage"
     widgetRestrictionGroups="AnyPage,SearchPage" >
      <property name="widgetOrientation"
       displayName="Widget Orientation"/>
      <property name="numberOfContentToDisplay"
       displayName="Maximum number of content to display"/>
    </widgetDef>
    </widget>
</pageLayout>
 
Use the JET Transformation to generate the source code files for creating your custom widget. 
 a.Right-click your pattern input XML file. Select Run As > Run Configurations.
 b.In the Run Configurations wizard, double-click JET Transformation from the list of filters. The configuration options for the JET Transformation display.
 c.Ensure that the value of the Name field is the name of your pattern input XML file.
 d.In the Main tab, ensure that the value of the Transformation Input field is the filepath within your workspace to the pattern input XML file. For example, NewWidgetProject\NewWidgetPatternInputFile.xml
 e.In the Transformation section, select com.ibm.commerce.toolkit.internal.pattern.pageLayout for the value of the ID field.
 f.Optional: Specify the severity level for the Display Message logging. The default value is information.
 g.Click Apply > Run. The JET Transformation generates the file directories and files for your custom widget at the location you specified in the targetFolder parameter in the pattern input XML file.
 h.Verify that the JET Transformation created the following directories and files.
 
After running the JET three project will create under “targetFolder”
 
  •Management Center - LOBTools
 •Storefront - Stores
 •Data Load utility - DataLoad.
 
 
 
If you are creating a custom site-level widget, create the following directory, if the directory does not exist:
  •WCDE_installdir\workspace\Stores\WebContent\Widgets-vendor
If you are creating a custom store-level widget, create a store-specific directory that contains the Widgets-vendor directory, if the directory does not exist:
  •WCDE_installdir\workspace\Stores\WebContent\store\Widgets-vendor
 
Copy the generated source code files for your widget storefront assets from your project folder to the appropriate location within the default Stores project.
a.        Expand your new project directory, go to Stores\WebContent.
b.        Right-click the Widgets-vendor directory. Select to Copy the directory.
c.        Go to the default Stores\WebContent directory.
d.        Paste the copied Widgets-vendor directory within the default WebContent directory.
Load widget into the database by using Data load utility
Use the Data Load utility to register your widget in the Commerce Composer framework and have your store subscribe to your widget. Update db details in wc-dataload-wideget-env.xml file.
·         Go to the WCDE_installdir\bin directory.
·         Run the following command to load the input CSV files to register your widget and have a store subscribe to your widget:
Dataload.bat workspace_dir\NewWidgetProject\DataLoad\widget\wc-dataload-widget.xml
Tables updated will be : PLWIDGETDEF, PLWIDGETDEFDESC, PLSTOREWIDGET, PLWIDGETNVP
 Extending the resource bundle and properties files
 Add the text for your widget within a properties file to ensure that the Management Center properties and list views for your widget display text.
Copy the generated resource bundle and properties files into your default workspace directory structure.
   1.Copy the generated resource bundle and properties files into your default workspace directory structure.
   a.In a File Manager, go to the com directory within your new widget project directory.
workspace_dir\NewWidgetProject\LOBTools\src\com.
    b.Copy the Widgets-vendor directory.
  c.Go to the workspace_dir\LOBTools\Java Resources\src directory.
  d.Paste your copied Widgets-vendor directory within the LOBTools\Java Resources\src directory.
  e.Right-click the LOBTools directory within your default workspace directory structure. Click Refresh.
  1.Define the translatable text for your new widget.
   a. In the Enterprise Explorer view, go to the LOBTools\Java Resources\src directory. Expand thecom.mycompany.commerce.pagelayout.client.lobtools.properties package. Open the PageLayoutLOB.propertiesand PageLayoutLOB_en_US.properties files for editing. The following generated code is included within the files:
# Widget properties view
widgetNamePrompt=Widget Name
widgetPropertiesPrompt=Widget Properties
widgetContentPrompt=Widget Content
ShoppingCartDetailPageWidgetContent = this widget displays the orders you add into your shopping cart
    b.Define any additional translatable text for your widget by adding code into both files.
  c.Save any changes and close the files.
  2.Copy the generated resource bundle extension into your default workspace directory structure and register your properties files.
   a.In your new project directory, go to the lzx directory. For example, the file path to the lzx directory can be NewWidgetProject\LOBTools\WebContent\WEB-INF\src\lzx.
  b.Copy the Widgets-vendor  directory.
  c.Go to the LOBTools\WebContent\WEB-INF\src\lzx directory.
  d.Paste your copied Widgets-vendor directory within the LOBTools\WebContent\WEB-INF\src\lzx directory.
  3.Update the default Commerce Composer resource bundle library to include your new resource bundle extension.
   a.In your new project directory, go to the directory. For example, the filepath to the lzx directory, can be NewWidgetProject\LOBTools\WebContent\WEB-INF\src\lzx\commerce\pagelayout.
  b.Open the PageLayoutExtensionsLibrary.lzx file to view the source code.
  c.Copy the generated code that includes your widget resource bundle. For example, the generated code can resemble the following code:
<library>
 <!-- Include the file to add any custom libraries. -->
  <include href="../../mycompany/pagelayout/mycompanyPageLayoutResourceBundle.lzx"/>
</library>
    d.Go to the LOBTools\WebContent\WEB-INF\src\lzx\commerce\pagelayout directory within your default workspace directory structure.
  e.Open the PageLayoutExtensionsLibrary.lzx file for editing.
  f.Paste your copied code within the PageLayoutExtensionsLibrary.lzx file.
  g.Save and close the file.
  Define the object definition for widget:
The object definition adds support for your widget object within the Management Center framework.
  1.In the Enterprise Explorer view, copy the generated object definition files for your widget into your default workspace directory structure.
  a.In your new project directory, go to the WebContent\config directory. For example, NewWidgetProject\LOBTools\WebContent\config.
 b.Copy the Widgets-vendor directory.
 c.Go to the LOBTools\WebContent\config directory in your default workspace directory structure.
 d.Paste the Widgets-vendor directory within the LOBTools\WebContent\config directory.
 2. In your default workspace directory structure, go to theLOBTools\WebContent\config\mycompany\pagelayout\widgetDefinitions\widgetName directory.
 3.Open the WidgetObjectDefinition.def file for editing. 
 4.Update the object definition file to change any of the default generated values or add more definition properties for your widget. Ensure that you update the file to specify an icon for your widget. For more information
 5.Save and close the file
Testing new widget in Management Center
·    Open CMC and create a new layout.
·    Assign a page to layout and add a widget to any slot in layout.  You will get custom widget in widget list.
 ·   Click on save and preview.
·   Click on show information. It will show widget details.
 
Enabling Commerce Composer widget caching in WebSphere Commerce Developer
 By default it is not enabled.
Open wc-server.xml
Add the following map:
 
<map className="com.ibm.commerce.dynacache.filter.DeviceFormatIdCallBack"
display="false"
dynacacheAttributeName="DC_deviceFormatId"
methodName="setDeviceFormatId"
name="setDeviceFormatId"/>

Working with pages in the Commerce Composer tool

The Commerce Composer tool gives you the freedom to quickly create and assemble the contents of your store pages without involving IT. By using a library of prebuilt layout templates and widgets, you can manage store page layouts directly in Management Center.
 
Working with pages in the Commerce Composer tool
 
In the Commerce Composer tool, a page is a specific URL on your storefront. You can create pages directly in the Commerce Composer tool.
 
Creating new page :
 
1. Select the Commerce Composer from Management Center
 
 
2.Choose the store from right side drop down
3. Select New content page folder by right click on content folder
4. Give page name as my new page
 

 
5. Now choose new content page
 
 
6. Name it as - "MyNewPage"

 
 
7. Save it and we take preview for same page. Since we have not created layout so we cant see any content on it.
 
 
8. Now create new layout by clicking on Layout folder:
 
9. Choose option as any page,Five slides right sidebar
 
10. Name it as "MyLayout"
 
 
11. In layout assignment brose for out created page (MyNewpage) on which we will set layout
 
 
 
 
12. In design layout we have sequence for page :
 
 
13. Click the Wireframe numbers (1,2,3,4,5), you will get the following popup
 

 
14. Select category recommendation and put it for slot 1.
 
 
15. Expand it to check option available :
 
15. Under category drag and drop from ur catalog. If it is store specific then select from sales catalog else from master catalog.
 

 
16. Preview the page to see output of page.
 
 
 
Changing the SEO properties for categories and catalog entries

 

In the explorer view:

  1. Expand the Catalog Pages folder.
  2. To change the URL keyword property, type a new keyword.

To change the Page title, Meta description, or Image alt text properties:
    1. Click Override default for the property.
    2. Type the value for the property in the field. For example, for the Furniture category page, you might change the Page title value to Welcome to the Aurora furniture department
 
 
Click Save and Preview.
 

Wednesday, November 19, 2014

sitemap generation in websphere commerce

Step I Login to Admin console as Site Admin.
 
Step II Navigate to Admin Consoleà Scheduler (Screenshot Attached below)
 
 

 
Step III
 
Select New,
 

 
 
 
 
Step IV
 
From the Dropdown of Job Command select , “SitemapGenerateand give the Job parameters
Passed storeId and catalogId for which we want the sitemap file,
 
We will create two jobs,
 
For first job,
 
In our case it was “storeId=10151&catalogId=10001” (without quotes), in the Start date give the date on which you want the scheduler to run, same for time field, give a relatively closer time.
 

 
Click ok and check the jobs status till its complete.


 
 
 


 
 
Once first job is complete schedule the second job, repeat step 5(III) onwards with job parameter as ‘storeId=10152&catalogId=10001
 
For each store we will get a separate sitemap_<<storeId>>.xml file inside WASPROFILE/temp
 
(In Dev environment it was located under “/opt/was7dv/AppServer/profiles/comm7dv01/temp’)
 
There will be two files sitemap_10151.xml and sitemap_10152.xml. We will move these two files inside WC_eardir /Stores.war
 
(DEV path /opt/was7dv/AppServer/profiles/comm7dv01/installedApps/WC_comm7dv01_cell/WC_comm7dv01.ear/Stores.war).

Now we will create an index file which will have entries of both these files. This index file will be submitted to google. Replace the <<severname>> part with the current server name
Name the file as sitemap.xml
 
<?xml version="1.0" encoding="UTF-8" ?>
<sitemap>
<loc>http://<<servername>>/webapp/wcs/stores/sitemap_10151.xml</loc>
<lastmod>2012-08-03</lastmod>
</sitemap>
<sitemap>
<loc>http://<<servername>>/webapp/wcs/stores/sitemap_10152.xml</loc>
<lastmod>2012-08-03</lastmod>
</sitemap>
</sitemapindex>
 
Step V
The sitemap.xml file is placed in the following directory for access by search engines:
·         WC_eardir /Stores.war
·         WCDE_installdir /workspace/Stores/WebContent
 
  • Copy this sitemap.xml in webserver location Stores.war.
 
( In Dev inside “/opt/commerce7dv/webcontent/Stores.war”)
  • And WC_eardir /Stores.war
 
(In DEV inside /opt/was7dv/AppServer/profiles/comm7dv01/installedApps/WC_comm7dv01_cell/WC_comm7dv01.ear/Stores.war )
 
 
 
 
 
Step VI
 
Access the sitemap.xml
 
We can access the file by typing the file name from our store URL ,
 

stagprop for custom table in IBM WCS


NOTE: If you want your custom table to be used in stagprop, Make sure table name doesnot exceed 18 CHAR length.

The stagingprop utility propagates staged data and managed files from the production-ready data to the production server. If you have customized your database schema by creating new tables and you want to stage these custom tables, perform the following steps for each custom table you want to stage.

Step 1 : Identify scope of table

To enabling custom tables for staging first we need to identify scope of table based on following three criteria :



Site data
The table records contain site changes. For example, new taxes or currencies. For site tables, insert only into STGSITETAB.
Merchant data
The table records contain store changes. For example, the STORE and CATENTRY tables are merchant tables. Typically, when a store ID exists in the table, it is likely a merchant table. For merchant tables, insert only into STGMERTAB.

insert into STGMERTAB values ('10003','x_attributes,NULL,NULL)
Mixed site and merchant data
The table records contain both site and store changes. These hybrid tables are defined in the STGSITETAB table. For hybrid tables, one of the table columns is used to decide whether the record is SITE or MERCHANT. This table column can be defined in the COLNAME column of the STGMRSTTAB table. For example, the MEMBER table uses MEMBER_ID to decide if the record is SITE or MERCHANT.

In both the staging server and the production server, insert the customized table into the STGSITETAB, STGMERTAB, or STGMRSTTAB table, depending on the scope of the table.
If you are inserting customized parent and child tables, ensure the TABNBR column value for the child tables are higher than the TABNBR column value for the parent tables.

Step 2 : Creating triggers for custom tables

We need to add SQL statements to create and drop triggers for the new table to the following files:
  •  WC_installdir/schema/db2/wcs.stage.trigger.sql
  • WC_installdir/schema/db2/wcs.droptrigger.sql

Gather the following information about the custom table:
  • table name
  • table scope (site, merchant, or mixed site and merchant)
  • primary or unique key columns
Put SQL statements to create three triggers for the custom database table in the wcs.stage.trigger.sql file. You must create three triggers:
  • An INSERT trigger to capture insert operations on the custom table.
  • An UPDATE trigger to capture update operation on the custom table.
  • A DELETE trigger to capture delete operations on the custom table.
Trigger naming convention
The trigger naming convention is a guideline to ensure that new triggers for custom tables have unique names.
 For DB2 : WebSphere Commerce names a trigger by incrementing that last number of the last trigger in the db2/wcs.stage.trigger.sql file. Do not use this naming convention for your new triggers as your custom trigger names could conflict with any new triggers introduced by WebSphere Commerce in fix packs or later releases.

INSERT trigger example(DB2)

This trigger logs INSERT actions in the STAGLOG table after an INSERT action happens on the CATGROUP table.
Create  trigger STAG0098
               AFTER INSERT ON catgroup REFERENCING NEW AS N
               FOR EACH ROW MODE DB2SQL
               BEGIN ATOMIC
     INSERT INTO staglog
     (  stgrfnbr
     ,  stgstmp
     ,  stgtable
     ,  stgop
     ,  stgmenbr
     ,  stgkey1name
     ,  stgokey1
     ,  stgnkey1
     )
     VALUES (
         NEXTVAL FOR STAGESEQ
      ,  CURRENT TIMESTAMP
      ,  'catgroup'
      ,  'I'
      ,  1
      ,  'catgroup_id'
      ,  N.catgroup_id
      ,  N.catgroup_id
     );
               END#

UPDATE trigger example (DB2)

This trigger logs UPDATE actions in the STAGLOG table after an UPDATE action happens on the CATGROUP table.

Create  trigger STAG0099
               AFTER UPDATE ON catgroup REFERENCING NEW AS N OLD AS O
               FOR EACH ROW MODE DB2SQL
               BEGIN ATOMIC
     INSERT INTO staglog
     (  stgrfnbr
     ,  stgstmp
     ,  stgtable
     ,  stgop
     ,  stgmenbr
     ,  stgkey1name
     ,  stgokey1
     ,  stgnkey1
     )
     VALUES (
         NEXTVAL FOR STAGESEQ
      ,  CURRENT TIMESTAMP
      ,  'catgroup'
      ,  'U'
      ,  1
      ,  'catgroup_id'
      ,  O.catgroup_id
      ,  N.catgroup_id
     );
               END#

DELETE trigger example

This trigger logs DELETE actions in the STAGLOG table after a DELETE action happens on the CATGROUP table.
Create  trigger STAG0100
               AFTER DELETE ON catgroup REFERENCING OLD AS O
               FOR EACH ROW MODE DB2SQL
               BEGIN ATOMIC
     INSERT INTO staglog
     (  stgrfnbr
     ,  stgstmp
     ,  stgtable
     ,  stgop
     ,  stgmenbr
     ,  stgkey1name
     ,  stgokey1
     )
     VALUES (
         NEXTVAL FOR STAGESEQ
      ,  CURRENT TIMESTAMP
      ,  'catgroup'
      ,  'D'
      ,  1
      ,  'catgroup_id'
      ,  O.catgroup_id
     );
               END#

Manually run the wcs.stage.trigger.sql script file to generate the triggers on the relevant table.
Note: To verify the triggers defined, you run the following SQL statements to query the system table ALL_TRIGGERS:
select * from all_triggers;

Friday, November 14, 2014

Create registry in IBM WCS


Registry is an alternate solution for those which can’t be cached using Dyna cache.
The Registry Manager maintains a set of registries for caching WebSphere Commerce runtime data. Each registry provides methods to enable adding, deleting, and refreshing of the registry content. These methods are available to the URL interface by using the ListRegistry and the RefreshRegistry commands.
If the data in the tables that are associated with a registry is changed, you must refresh that registry for the change to take effect.
 

Steps to Create  a new custom registry in WCS
 
1. Register the registry in wc-server.xml.
<Registries>
--
--
--
<registry initialCapacity="20" name="ShippingRegistry" regClassName="com.XXX.commerce.fulfillment.registry.XXXShippingRegistry"/>
</Registries>
2.Create  a class that implements   interface com.ibm.commerce.registry.Registry

package com.XXX.commerce.fulfillment.registry;
 
import java.util.HashMap;
import com.ibm.commerce.exception.ECException;
import com.ibm.commerce.registry.Registry;
import com.ibm.commerce.registry.RegistryManager;
 
public  class XXXShippingRegistry implements Registry {
                  
                /**
                 * This method initializes the registry. It is being called when server starts.
                 */

                public void initialize() throws Exception {
               
                                RegistryManager.singleton().addRegistry("CustomRegistry  ", this);
                                try {
                                                this.initialRegistry();
                                } catch (ECException e) {
                                                e.printStackTrace();
                                }
                                                }

                /**
                 * This method is used to refresh the registry. It is being called when user
                 * updates the registry through Site Admin console.
                 */
                public void refresh() throws Exception {
               
                final String methodName = "refresh";
                if (TraceLogger.isLoggable(Level.INFO))
               TraceLogger.entry(CLASSNAME, methodName);

                       HashMap shippingRangeMapCache = new HashMap();
           populate();

 
                 if (TraceLogger.isLoggable(Level.INFO))
                         TraceLogger.exit(CLASSNAME, methodName);
                               
                             }

/**
* This method implements how the cached registry is populated.
*
* @param aCache
* HashMap
* @throws Exception
* e
*/
private synchronized void populate() throws Exception {
final String methodName = "populate";
if (TraceLogger.isLoggable(Level.INFO))
TraceLogger.entry(CLASSNAME, methodName);
//populate shipping ranges
shippingRangeMapCache = XXXShippingHelper.getInstance().populateShippingRanges();

initialized = true;
//TraceLogger.trace(CLASSNAME, methodName, "shippingRangeMapCache --> "+shippingRangeMapCache);
if (TraceLogger.isLoggable(Level.INFO))
TraceLogger.exit(CLASSNAME, methodName);
}
}

Login to Admin Console->Registry->check the CustomConfigRegistry registry and update.
or
Directly refresh
http://myhostname/webapp/wcs/stores/servlet/RefreshRegistry?URL=/webapp/wcs/Admin/homepg&registryName=CustomConfigRegistry