Freigeben über


Product Query Web Part

The Product Query Web Part provides flexible delivery of search results. You can use the result list to, for example, produce a full list of products in a category complete with paging, or a view of featured products. In addition it may act as a master Web Part that feeds the list of products to other Web Parts through Web Part connections, such as a product editing Web Part. The Product Query Web Part supports the following URL parameters:

  • The category name or ID

  • The current page of product results

The Product Query Web Part is an XSLT driven Web Part responsible for rendering a list of products within a category. In addition, the Product Query Web Part can expose its list of products to consuming Web Parts by acting as a provider Web Part through Web Part connections.

Architecture

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

  • The category is provided by the SharePoint site through a configurable query parameter and is consumed by the Product Query Web Part.

  • The Product Query Web Part retrieves a list of products by calling the Commerce Server 2009, and passing the category and the list of properties to retrieve. 

  • After the Product Query Web Part retrieves the product list, it generates XML and then calls the XSLT provided by the user to produce HTML output.

  • The output HTML is rendered by the Product Query Web Part to the SharePoint site.

The list of products can be consumed by any other Web Part through Web Part connections if you configure it to do so.

Properties

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

Property

Map to

Catalog

Catalog

"Catalog" URL parameter

CatalogUrlKey

Category

Category

"Category Id" URL parameter

CategoryIdUrlKey

Channel

Channel

Include "Cross -Sells"

IncludeCrossSells

Include "Relationships"

IncludeRelationships

Include "Up-Sells"

IncludeUpSells

Include "Variants"

IncludeVariants

Maximum # results per page

MaxResultsPerPage

"Sort Direction" URL parameter

OrderByDirectionUrlKey

"Sort By" URL parameter

OrderByUrlKey

"Page Number" URL parameter

PageNumberUrlKey

Page title format

PageTitle

"Sort By" options

SortingPropertiesTemplate

Customization

You can do customization through XSL transformations and Web Part parameters.

XSLT actions need to pass in two things when being instantiated. The first is a [ProductContext] that contains strongly typed properties that the XSLT action can query. The collection of products that the Product Query Web Part retrieves is made available to an XSLT action control through this [ProductContext]. The second is a collection of configuration settings that are defined in the markup of the XSLT action and that you use to configure the XSLT action. For instance, the pager XSLT action requires a value for the string to use to display as the text for a "Previous" button or for the "Next" button.

When working with the Product Query Web Part (or the XSLT Property List Web Part) you may want to view the raw XML that is rendered before the XSL transform is applied in order to optimize your XSLT code. The code below lets you view the raw XML:

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">

<xmp><xsl:copy-of select="*"/></xmp>

</xsl:template>

</xsl:stylesheet>

Note When selecting the Template Properties using the Select Properties Webpage Dialog, only the Selected Properties will be displayed by the Product Query Web Part.

Note If you create a custom Transform, you must select the property you want to display from both the Selected Properties and the Selected Variant Properties group in the Select Properties Webpage Dialog.

Error Handling

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

Design Time Validation

The following table lists the fields that the Product Query Web Part validates at design time.

Field

Description

Occurs

System response

XslTransform

Validates that the XSL transform is correctly formed.

When saving an XSLT template.

Displays an error indicating that the XSL transform is not valid.

Run Time Validation

The following table lists the fields that the Product Query Web Part validates at run time.

Field

Description

Occurs

System response

Category

Validates if the category is passed in as a query string URL parameter.

When rendering the Product Query Web Part.

Displays an error indicating that the category query string URL parameter is required.

MaxResultsPerPage

Validates if MaxResultsPerPage has been set.

When rendering the Product Query Web Part.

Displays an error indicating that the MaxResultsPerPage field is required.

Channel

Validates if the Channel field has been set.

When rendering the Product Query Web Part.

Displays an error indicating that the Channel field is required.

Catalog

Validates if the Catalog field has been set.

When rendering the Product Query Web Part.

Displays an error indicating that the Catalog field is required.

API Dependencies

The dependencies on the API are:

  • Performing a full text query

  • Returning a list products for a specific category

  • Returning a list of products filtered by additional properties

  • Returning a subset of the list of products defined by the number of results to return (use for paging)

  • Must be able to sort the list of products by ascending or descending order by a given property

  • Must be able to support grandparent/grandchild relationships

  • Must be able to return up sells of products

  • Must be able to return cross sells of products

  • Must be able to return custom relationships of products

  • Must be able to return variants of products

See Also

Other Resources

Developing with SharePoint Commerce Services

Catalog System Web Parts

Working With the Product Query Web Part