Monday, August 26, 2013

Cross-Site Links - Commerce Referrence Store


Cross-Site Links 


Commerce Reference Store includes cross-site links to ATG Home products on the ATG Store site, and links to ATG Store products on the ATG Home site. Cross-site product links appear in the following places:


Search results , Recommended products on the home page ,  Promotional content items that contain target links, Related products on the product detail page, Recently viewed products on the product detail page, Gift and wish lists, Shopping cart, Product comparisons


Commerce Reference Store uses the servlet beans /atg/commerce/multisite/SiteIdForCatalogItem (of class atg.droplet.multisite.SiteIdForItemDroplet) and /atg/dynamo/droplet/multisite/SiteLinkDroplet (of class atg.droplet.multisite.SiteLinkDroplet) to create cross-site links


The following example is adapted from store.war/global/gadgets/crossSiteLinkGenerator.jsp:


<%-- Pass a product repository item to the SiteIdForCatalogItem droplet to
determine the best-matching site ID for the product. --%>
<dsp:droplet name="/atg/commerce/multisite/SiteIdForCatalogItem">
   <dsp:param name="item" param="product" />
   <dsp:oparam name="output">

      <%-- Store the site ID obtained by SiteIdForCatalogItem in a productSiteId
      variable. --%>
      <dsp:getvalueof var="productSiteId" param="siteId" />

      <%-- Pass the site ID and the product's template path to SiteLinkDroplet to
      get a site-specific URL to the product template. --%>
      <dsp:droplet name="/atg/dynamo/droplet/multisite/SiteLinkDroplet">
         <dsp:param name="siteId" value="${productSiteId}" />
         <dsp:param name="path" param="product.template.url" />
         <dsp:oparam name="output">

            <%-- Render the generated URL to the product template, appended with
            the product ID. --%>
            <dsp:getvaluof var="siteLinkUrl" param="url" />
            <dsp:a href="${siteLinkUrl}">
               <dsp:param name="productId" param="product.repositoryId" />
               <dsp:valueof param="product.displayName" />
            </dsp:a>

         </dsp:oparam>
      </dsp:droplet>
   </dsp:oparam>
</dsp:droplet>



This example generates the URL as follows:


1. The SiteIdForCatalogItem servlet bean determines the best site ID to use for the product.

2. The SiteLinkDroplet servlet bean uses the siteId returned by SiteIdForCatalogItem to determine which site the URL should point to and it retrieves the value of the productionURL property for that site. For example, if the link is to a product on ATG Store US, the value of productionURL is /crs/storeus. Note that, in this example, productionURL does not contain domain information, so the URL that SiteLinkDroplet produces also does not include this information. Consequently, the browser will use the current page’s protocol, domain, and port information for the link.

3. The product template portion is taken from the product’s product.template.url property, which is passed to SiteLinkDroplet in its path parameter.

4. The <dsp:a> tag appends the productId to the URL as a query parameter.



The resulting URL looks similar to this:


/crs/homeus/browse/productDetailSingleSku.jsp?productId=xprod2126



No comments:

Popular Posts