Skip to content
On this page

useProductSearchSuggest ​

Definition ​

Composable for product suggest search.

Basic usage ​

ts
const { 
 searchTerm,
 loading,
 getProducts,
 getTotal,
 search,
 loadMore 
} = useProductSearchSuggest();

Signature ​

ts
export function useProductSearchSuggest(): UseProductSearchSuggestReturn 

Return type ​

See UseProductSearchSuggestReturn
ts
export type UseProductSearchSuggestReturn = {
  /**
   * Current search term
   */
  searchTerm: Ref<string>;
  /**
   * Indicates if the search is in progress
   */
  loading: ComputedRef<boolean>;
  /**
   * Performs the search
   * @param additionalCriteria - additional search criteria of type {@link ShopwareSearchParams}
   * @returns
   */
  search(
    additionalCriteria?: Partial<RequestParameters<"searchPage">>,
  ): Promise<void>;
  /**
   * Loads more products for current search criteria
   */
  loadMore(criteria: RequestParameters<"searchPage">): Promise<void>;
  /**
   * Returns the product list found by the search
   */
  getProducts: ComputedRef<Schemas["ProductListingResult"]["elements"]>;
  /**
   * Returns the total number of products found by the search
   */
  getTotal: ComputedRef<number>;
};

Properties ​

NameTypeDescription
searchTerm
Ref<string>
Current search term
loading
ComputedRef<boolean>
Indicates if the search is in progress
getProducts
ComputedRef<>
Returns the product list found by the search
getTotal
ComputedRef<number>
Returns the total number of products found by the search

Methods ​

NameTypeDescription
search
Promise<void>
Performs the search
loadMore
Promise<void>
Loads more products for current search criteria
useProductSearchSuggest has loaded