Sana Assistant (online)
Table of Contents

UseProductListPage hook

const productListPage = useProductListPage();

When content element add-on is located on product list page it may need to access data about current page. This hook returns the object with data or null if it's not being used on the product list page.

The data contains following properties:

Property Type Description
categoryId string | undefined The product category ID all products of which belong to the product list page. Can be undefined in case product list page contains products from multiple categories.
productSetId string | null The ID of the product set associated with the product list page.
selectedFacets Array<RangeFacet | ListFacet> The selected facet filters.

The RangeFacet type contains following properties:

Property Type Description
name string The facet name.
minValue number The minimum value of the range facet.
maxValue number The maximum value of the range facet.

The ListFacet type contains following properties:

Property Type Description
name string The facet name.
values Array<string> The facet values.

Example:

  const productListPage = useProductListPage();

  if (!productListPage)
    return null;

  const { categoryId, productSetId, selectedFacets } = productListPage;