Skip to content
On this page

useProductSearch ​

Definition ​

Composable for product search.

Basic usage ​

ts
const {  search } = useProductSearch();

Signature ​

ts
export function useProductSearch(): UseProductSearchReturn 

Return type ​

See UseProductSearchReturn
ts
export type UseProductSearchReturn = {
  /**
   * Searches for a product by its id
   * @param productId
   * @param options - optional parameters accepts `withCmsAssociations` flag to fetch cms-related associations and criteria
   * @returns {Promise<Schemas['ProductDetailResponse']>}
   */
  search: (
    productId: string,
    options?: UseProductSearchReturnOptions,
  ) => Promise<Schemas["ProductDetailResponse"]>;
};

Properties ​

NameTypeDescription
search
(
    productId: string,
    options?: UseProductSearchReturnOptions,
  ) => Promise<Schemas["ProductDetailResponse"]>
Searches for a product by its id

Usage ​

ts
import { useProductSearch } from "@shopware-pwa/composables-next";

const { search } = useProductSearch();
useProductSearch has loaded