Working with the Product Provider Web Part

The Product Provider Web Part retrieves a set of properties from Microsoft Commerce Server 2009 R2, and then dispenses these properties through a Web Part connection. The selection of the properties to retrieve is based on the properties selected by consumer Web Parts. The Product Provider Web Part builds a master list of properties by requesting each consumer Web Part to submit its list of properties to retrieve. This logic is performed during runtime, thus ensuring the Product Provider Web Part will compile the most up to date list of properties.

Each consumer Web Part implements an interface that provides a method for the Provider Web Part to call in order to retrieve the properties for the Web Part. In addition, consumer Web Parts are able to make use of a Web Part parameter pane option to let the user set the list of properties, thus affecting the properties retrieved by the Provider Web Part.

In addition to the selection of individual product properties, relationships are selectable. These relationships are:

  • Cross sells (included by default)

  • Up sells (included by default)

  • Variants

  • Related items

  • Custom relationships

For information about how to retrieve and add new relationships, see Adding custom relationships to the "Include Relationships" action property

The Product Provider Web Part is headless, meaning that no evidence of its existence is shown on the Product Details page outside of Edit mode.

The Product Provider Web Part supports the following URL parameters, which are provided automatically by the site map providers:

  • The category name or ID

  • The product ID to retrieve properties about

There is a maximum of one Product Provider Web Part on any Product Details page. This is enforced at design time. Any Web Parts that require the Product Provider Web Part to be present emit an appropriate error or warning message to that effect when positioned on a site page.

Architecture

The sequence of actions of how this Web Part works is:

  1. The product identification is provided a configurable query parameter and is consumed by the Product Provider Web Part.

  2. The Product Provider Web Part builds a master list of product properties and variant properties to retrieve from all connected consumer Web Parts.

  3. The Product Provider Web Part retrieves a product based on the product identification, and the list of product properties and variant properties to retrieve.

  4. The product object is provided to other consumer Web Parts through Web Part connections.

Properties

The following table lists the mapping of the properties for the Product Provider Web Part.

Property

Type

Maps to

Description

Default

Include "Cross Sells"

Boolean

IncludeCrossSells

When checked, includes cross-sell options when retrieving information.

False

Include "Up Sells"

Boolean

IncludeUpSells

When checked, includes up-sell options when retrieving information.

False

Include "Variants"

Boolean

IncludeVariants

When checked, retrieves all product variant information from Commerce Server 2009 R2.

False

Include "Product Images"

Boolean

IncludeProductImages

When checked, includes all product images.

False

Include "Variant Images"

Boolean

IncludeVariantImages

When checked, includes images of variants.

False

Include “Relationships”

Boolean

IncludeRelationships

When checked, includes product relationships.

False

Product Page Title

String

ProductPageTitle

Title of the product page; the default of "%Product%" uses the product page title as it is in Commerce Server 2009 R2.

%Product%

Channel

String

Channel

Specifies the channel used by the Product Provider Web Part.

"default"

Catalog

String

Catalog

Specifies the catalog in Commerce Server 2009 R2 that the Product Provider Web Part will connect to; enter the name of the catalog using the Commerce Server 2009 R2 name (such as "Adventure Works Catalog").

NA

“Product Id” URL parameter

String

ProductIdUrlKey

Specifies the text in the URL query string that identifies the product id.

“pid”

"Catalog" URL parameter

String

CatalogIdUrlKey

Key used to access the catalog in shortMojave.

"cid"

“Category Id” URL parameter

String

CategoryIdUrlKey

Specifies the text in the URL query string that identifies the category id.

“category”

Customization

Adding custom relationships to the "Include Relationships" action property

By default, when you select the Include Relationships option, only defined cross-sells and up-sells relationships are included. To retrieve and display other relationship types when you select the option Include Relationships, you must perform the following procedure.

Note

The following procedure is based on a scenario where a new relationship called "MyRelationship" was created using Catalog Manager. The procedure walks you through the steps required to include retrieve and display this new relationship when the option Include Relationships is selected in the Product Provider Web Part.

To retrieve and display a new relationship:

  1. Create a new operation sequence component definition for the new relationship

  2. Update MetadataDefinitions for the new operation sequence component

  3. Enable the display of relationships on the Product Provider Web Part or Product Query Web part

Create a new operation sequence component definition for the new relationship

  1. Open the ChannelConfiguration.config file and then locate the CommerceQueryOperation_Product operation sequence.

    Note

    The ChannelConfiguration.config file is located in the following directory: %Inetpub%\wwwroot\wss\VirtualDirectories<Port number>

    Note

    When you use SharePoint Commerce Services, you must update these files for each site.

  2. Copy the section defining the "Up-Sell Provider" operation sequence component and paste it in immediately after that same section (under the "Up-Sell Provider" operation sequence).

  3. Rename the copied component to My Relationship Provider. This defines the operation sequence to use for the relationship that you want to retrieve.

  4. Update the CommerceServerRelationshipConfiguration element so that it can find the CrossSell relationship and the UpSell relationship. To do this, change the value of the CommerceServerRelationshipName property to "MyRelationship".

  5. Change the InternalRelationshipName property to the name of the relationship that you want to use when you query the Commerce Foundation API. This name will also be used to create the child element collection that contains the relationship results in the query response.

    Note

    You can use different strings for these properties. For example, in the AdventureWorks Catalog, you can find the CrossSell relationship in Catalog Manager. However, calls from SharePoint Web parts specify "CrossSells."

    After you make these changes, your new configuration section should be similar to the following:

    <Component name="My Relationship Provider" type="Microsoft.Commerce.Providers.Components.ProductCommerceServerRelationshipProcessor, Microsoft.Commerce.Providers, Version=1.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35">
        <Configuration    customElementName="CommerceServerRelationshipConfiguration" customElementType="Microsoft.Commerce.Providers.Components.CommerceServerRelationshipConfiguration, Microsoft.Commerce.Providers, Version=1.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35">
            <CommerceServerRelationshipConfiguration commerceServerRelationshipName="MyRelationship" internalRelationshipName="MyRelationship"/>
        </Configuration>
    </Component>
    

    This completes the tasks of creating a new operation sequence for the new relationship.

Update MetadataDefinitions for the new operation sequence component

  1. Open the MetadataDefinitions.xml file then locate the Product Definition section.

    Note

    The MetadataDefinitions.xml file is located in the following directory: %Inetpub%\wwwroot\wss\VirtualDirectories&lt;Port number>

  2. Locate the following section of the xml file: <CommerceEntity name="Product">.

  3. Under the <Relationships> element, locate, copy and then paste the definition of the CrossSells relationship element.

  4. Rename the copied CrossSells relationship definition to MyRelationship.

  5. Update the MyRelationship relationship definition element.

    After you make these changes, the section defining the new relationship element should be similar to the following:

    <Relationship name="MyRelationship" type="CatalogRelationship" modelName="HierarchicalCatalogEntity" isMultipleItems="true" >
        <DisplayName value="MyRelationship Products">
        </DisplayName>
        <Description value=" MyRelationship Products">
        </Description>
    </Relationship>
    

    This completes the tasks of updating MetadataDefinions for the new operation sequence component.

Enable the display of relationships on the Product Provider Web Part or Product Query Web part

  1. On the Product Provider Web Part or the Product Query Web Part, select the Include Relationships checkbox.

    The new relationship MyRelationship is listed with other existing relationships.

  2. Update the transforms used to display the output of Product Query Web Part and Product Details Web Part (for more information, see Working with the Product Details Web Part and Working with the Product Query Web Part.

    The XML feed into the transform engine now contains an XML element collection that is named MyRelationship. The following example shows a transform based on the CrossSell transformation:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" version="1.0" indent="yes" />
  <xsl:param name="_category" />
  <xsl:param name="DefaultImagesRepository" />
  <xsl:param name="_catalog" />
  <xsl:template match="/">
    <xsl:apply-templates select="products/product/MyRelationship" />
  </xsl:template>
  <xsl:template match="products/product/MyRelationship">
    <div class="ms-bold">My Relationship Items</div>
    <br />
    <table>
      <tr>
        <td>
          <xsl:apply-templates select="product|category" />
        </td>
      </tr>
    </table>
…

This completes the tasks of adding custom relationships to the "Include Relationships" action property.

Error Handling

There is no design-time error handing required for this Web Part.

See Also

Other Resources

Developing with SharePoint Commerce Services

Developing with Catalog Web Parts

Product Provider Web Part