Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

developerWorks Community:

  • Close [x]

Creating solutions on the extended sites framework in WebSphere Commerce

Part 1: Using the command layer

Michael DJ Shields (mshields@crossview.com), Solution Architect, CrossView, Inc.
Photo of Michael Shields
Michael Shields works for CrossView®, Inc. He has over a decade consulting and developing strategies to best leverage WebSphere Commerce to match client business requirements. He also has over twelve years of developing interactive web solutions using J2EE, PHP, Zend Framework, Adobe products, HTML, CSS, AJAX, jQuery, DOJO and JavaScript. Michael holds 5 patents, published over 12 tutorials on the WebSphere Commerce Information Center, and 10 tutorials on the developerWorks WebSphere Commerce zone. He holds over 12 technical certifications and a designation as a project manager (PMP).
Quan Nguyen (qnguyen@crossview.com), Solution Architect, CrossView, Inc.
Photo of Quan Nguyen
Quan Nguyen has been working for CrossView, Inc., since 1999, consulting and developing e-business solutions by leveraging WebSphere Commerce. As a Solution Architect, he has over a decade of experience, working with major B2C and B2B companies to implement robust WebSphere Commerce strategies, fulfilling their business requirements.
Raj Sanghvi (rsanghvi@crossview.com), Solution Architect, CrossView, Inc.
Photo of Raj Sanghvi
Raj Sanghvi is a Solution Architect for CrossView, Inc. He has over 6 years of experience consulting in WebSphere Commerce working for different sub systems. He also has over 10 years of experience doing software development using J2EE, Oracle, HTML, XML, and SOAP. He holds over 8 technical certifications and a designation as a project manager (CAMP). He has a Master's degree in Computer Science.
Amar Desai (amar.desai@atech.com), Solution Architect, Ascendant Technology
Photo of Amar Desai
Amar Desai is a Solution Architect at Ascendant® Technology. He has helped many top retail, banking, and dining companies materialize their vision in the e-commerce space using WebSphere Commerce. He has a penchant for applying the latest web application trends such as social commerce, precision marketing, and mobile commerce. He is a certified WebSphere Commerce developer and administrator.

Summary:  The purpose of extended sites in WebSphere® Commerce is to ensure sharable assets among different stores. This tutorial provides insight into different ways to use the store path resource that is an available-to-market framework in WebSphere Commerce. A new concept is introduced in this tutorial that provides provide granular levels of sharing with a sub-set of assets. Also, this tutorial describes how to properly extend an EJB to use the BeanFinderObject for your findBy methods to incorporate sharing queries. You will learn how to better ensure that your store's conglomerate is fully capable to share all of the integral assets to make your business successful, while keeping your software reusable and easy to maintain.

Date:  20 Oct 2010
Level:  Intermediate PDF:  A4 and Letter (143 KB | 53 pages)Get Adobe® Reader®

Activity:  23828 views
Comments:  

Affiliate networking using the store relationship types

Prerequisites

In the remaining sections of this tutorial, you will begin to incorporate custom support for a store's relationship to new assets. The general sequence is:

  1. Populate a new entry in the database in the STRELTYP table for the new shared asset type (com.dw.commerce.storepath.affiliate).
  2. Populate entries in the STOREREL table for defining store relationships based on the new STRELTYP entry.
  3. Modify the way the EJB is generated to introduce a new finder type and finder method for specifically resolving store relationships for new assets.
  4. Create a new databean to pull the definitions populated by the store relationship type (STRELTYP table). This bean incorporates the hierarchy logic imposed by the STOREREL.sequence field.

In this section, you will make changes to your database for testing purposes. You will also be required to use the Accelerator. Therefore, ensure that your access is permittable and that you have adequate access control capabilities to perform administrative tasks.

The best way to understand how to leverage store relationship types is to put real world context into using it. Why else would you make the decision to put the time into learning from a tutorial without real world context? For this tutorial, the concept of "affiliate networking" is a good way to introduce a new business asset into the world of extended sites. Affiliate networking can be designed to compliment the organizational behavior of the store flow. It is mutually exclusive to the core of the e-commerce engine so it is an invasive addition to leverage the extended site framework for the purposes of this tutorial.

One goal of affiliate networking in the context of an e-commerce solution is to provide a commission to third parties that provide throughput of a sale for a store. Organization tables are reused to represent affiliates. However, for this tutorial, an alternative set of tables are reused to representing affiliates, such as the VENDOR tables in WebSphere Commerce.

Predominantly, vendors in WebSphere Commerce are intended to be represented as a source for merchandise received at a fulfillment center, or expected to be received at a fulfillment center. In the case of affiliate networking to be used with the store relationships, as an example, the vendor tables are reused for this purpose, and the functionality is extended to represent them as affiliates. Of course, you can later integrate referrals to these vendors if you like this solution, but this tutorial is focusing only on illustrating the power of extended sites and how to keep the code reusable and clean. Referrals that are measured for recognition purposes through various techniques that include clickstream analysis, clickthrough rates, affiliate marketing services, and surveys can simply be integrated by associating with the vendors that you have flagged as affiliates.

Note: The affiliate design of using vendor tables is for illustration purposes only for this tutorial. If vendors are already being used for the intended purpose as a source for merchandise received at a fulfillment center, or expected to be received at a fulfillment center, then new vendors need to be created and flagged so as not to be marked with fulfillment centers. Unless, of course, you create new fulfillment centers that do not conflict with the dominating engine powering your e-commerce solution.

For the purposes of this tutorial, you will merely populate minimal data for vendors so as to illustrate how they can participate in an extension of the store path relationships.

Creating affiliates as a relationship type

Affiliates are easily incorporated into the organization model provided by WebSphere Commerce. Affiliates can also create new extended tables into the WebSphere Commerce database. The vendor tables are a great fit since they are maintained easily in the Accelerator, and serve the purpose for the illustration of this tutorial.

You will create affiliates on both the Catalog Asset Store level as well as the hosted store level in the Accelerator.

  1. Open the file WCDE Installation Directory/xml/tools/common/CommerceAcceleratorCPS.xml.
  2. Search for the following lines of code:

    Listing 4. Accelerator CommerceAcceleratorCPS product menu element
    
    <menuitem name="products"
                 enabled="true"
                 taskUsages="all"
                 users="catMgr">
    	.......
    </menuitem>

  3. Add the following lines within the product menu item, preferably at the end:

    Listing 5. Accelerator CommerceAcceleratorCPS appending vendor menu sub-item
    
    <node  name="separator"
      url=""/>
    <node  name="vendors"
      url="$webapp_accelerator$NewDynamicListView?
       ActionXMLFile=inventory.VendorList&amp;cmd=VendorListView"
      users="catMgr mchMgr"/>
    <node  name="separator"
      url=""/>

  4. Save the file WCDE Installation Directory/xml/tools/common/CommerceAcceleratorCPS.xml. The changes you have enabled allow vendor data maintenance on the Catalog Asset Store level.
  5. Restart the development environment server.
  6. Log into the Accelerator and select the Catalog Asset Store as the store. Note: Ensure that your tooling administrator has the Category Manager role assigned for this organization level.
  7. Create a Catalog Asset Store level affiliate by creating a vendor using the Accelerator. For the name and address and contact information sections, create something measurable to ensure future tutorial steps are properly evaluated. For example, AffiliateAssetLevel1 and AffiliateAssetLevel2.
  8. Select the Stores selection button to change to another store, preferably Example1 being the first hosted store that you created. Note: Ensure that your tooling administrator has the Category Manager role assigned for this organization level.
  9. Create a Hosted Store level affiliate by creating a vendor using the Accelerator. For the name and address and contact information sections, create something measurable to ensure future tutorial steps are properly evaluated. For example, AffiliateHostedLevel1 and AffiliateHostedLevel2.

Once the affiliates are populated, you will test by listing the affiliates that are shared and specific for the hosted store together.


First time at the code

This will be your first use of the code to not only understand how store path relationships work, but also incorporate newly formed shared assets into your environment. For this section, you will introduce new code into the WebSphere Commerce system and learn how to reuse the same code base between managing the hosted store level assets and managing the shared assets.

Link to the Download section of this tutorial to get the zip package corresponding to the code for this tutorial. Install the classes DWStorePathVendorViewBean.java and DWStorePathVendorConstants.java into the WebSphereCommerceServerExtensionsLogic project under the src directory, build the project, restart the server.

To get the code to list the vendors, follow these steps:

  1. Choose a hosted store page that you want to customize to list the affiliates. For example, open the file WCDE Installation Directory/workspace/Stores/WebContent/ShoppingArea/CatalogSection/CategorySubsection/TopCategoriesDisplay.jsp.
  2. Append these lines into the JSP within the body of the HTML section of the file:

    Listing 6. JSP appending DWStorePathVendorViewBean for Listing Affiliates
    
    <wcbase:useBean id="dwVendor" 
     classname="com.dw.commerce.common.storepath.beans.DWStorePathVendorViewBean" 
     scope="request" />
      <c:if test="${not empty dwVendor.vendorsList}">
       Affiliates:<br/>
       <c:forEach var="vendorsList" items="${dwVendor.vendorsList}" >
    	 <c:out value="${vendorsList.vendorId}" escapeXml="false" />
    	 <c:out value="${vendorsList.vendorName}" escapeXml="false" />
    	 <br/>
       </c:forEach>
      </c:if>

  3. Open a browser to the hosted store page (for example,Hosted Store Example1) corresponding to the JSP file that you added the code excerpt (for example, TopCategoriesDisplay.jsp). Note: Affiliates may throw an access control error if your user is not logged into the store, some additional roles may have to be applied. The site administrator role may be applied to a user temporarily for the purposes of displaying this data. However, you can load a granular level access control to enable vendors to be reused in the future.
  4. Once the page has loaded, the results is that you see affiliates for those vendors you added on the hosted store level only.

What you have done so far is show the affiliates (vendor data) that belong to the hosted store level only. You have not displayed the affiliates (vendor data) that belong to the asset store level, or otherwise known as shared affiliates assets. An easy way to verify this is to open up another hosted store that resides under the same asset store. You have deployed a common asset store and under that store you have created hosted store Example1 and hosted store Example2.

Open up a browser to the other hosted store page (for example, Hosted Store Example2). Without access to shared assets, there are no affiliates showing up in that store because there are no affiliates (vendor data) populated for that store level. You have not yet made the shared assets available to these stores. No need to worry, you do not have to make any more code changes from this point forward to view any newly created shared assets. All shared assets are now supported by the way the store relationships are defined.


Populating the store relationships for affiliates

In this section, you will create a custom store relationship type. You will then use that store relationship type as the designated asset for affiliates, thus allowing the asset level shared data to show up on the hosted store level.

  1. Ensure the test environment is started.
  2. From your database, prepare to execute an SQL statement. For example, with the toolkit, open a browser, and type the following URL: http://localhost/webapp/wcs/admin/servlet/db.jsp.
  3. From your database, execute the following query:

    Listing 7. JSP appending DWStorePathVendorViewBean for Listing Affiliates
    
    delete from streltyp where name = 'com.dw.commerce.storepath.affiliate';
    
    insert into streltyp (name,streltyp_id) 
    values ('com.dw.commerce.storepath.affiliate',5);
    
    insert into storerel (streltyp_id,relatedstore_id,store_id,sequence,state)
    values (
    (select streltyp_id from streltyp where name = 
    'com.dw.commerce.storepath.affiliate'),
    (select store_id from store where directory = 'Example1'),
    (select store_id from store where directory = 'Example1'),1,1)
    
    insert into storerel (streltyp_id,relatedstore_id,store_id,sequence,state) 
    values (
    (select streltyp_id from streltyp where name = 
    'com.dw.commerce.storepath.affiliate'),
    (select store_id from store where directory = 'ExampleCatalogAssetStore'),
    (select store_id from store where directory = 'Example1'),0,1)

  4. Commit the executed SQL statements on your database and restart the WebSphere Commerce test server.
  5. Open a browser to the hosted store page (for example, Hosted Store Example1) corresponding to the JSP file that you added the code excerpt (for example, TopCategoriesDisplay.jsp). Note: Affiliates may throw an access control error if your user is not logged into the store. Some additional roles may have to be applied. The site administrator role may be applied to a user temporarily for the purposes of displaying this data. However, you can load a granular level access control to enable vendors to be reused in the future.

The resulting behavior is that you can see both the asset store level and hosted store level affiliate data displayed on the page. You can see the difference between restricting the view to the store level only and viewing the shared data without any additional code changes. All that was necessary was a database entry to view the changed behavior on the extended site instance. The code that you have introduced to your environment has some additional rule flags that you can set that will allow you to provide an even more granular level of display. For example, you have the option to:

  • Show the hosted store level data only.
  • Show the hosted store level data and show the asset store level shared data together.
  • Show the asset store level shared data only.

You can also log into the other hosted stores in your environment using the same JSP that you customized. For example, if you logged into the hosted store Example2, you also see the affiliate data that belongs to the asset store level. Without any code changes, using a common set of code, you have influenced all of your hosted stores to display a common shared set of data.

Section conclusion

For the first customization exercise, you have customized the store relationships to introduce new assets into your extended site environment. The advantages to this exercise is that you have a common set of code that can easily display store level or asset store level shared data. In the next section, you will create a new entity bean and learn how to incorporate the store path relationships directly onto the EJB layer itself. This gives you the flexibility to incorporate custom store relationship types into different layers of your application.

4 of 11 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=551401
TutorialTitle=Creating solutions on the extended sites framework in WebSphere Commerce
publish-date=10202010
author1-email=mshields@crossview.com
author1-email-cc=dwu@us.ibm.com
author2-email=qnguyen@crossview.com
author2-email-cc=dwu@us.ibm.com
author3-email=rsanghvi@crossview.com
author3-email-cc=dwu@us.ibm.com
author4-email=amar.desai@atech.com
author4-email-cc=dwu@us.ibm.com