Skip to content

useProductAssociations ​

Definition ​

Get product association entity.

Basic usage ​

ts
const { 
 isLoading,
 productAssociations,
 loadAssociations 
} = useProductAssociations(product, options);

Signature ​

ts
export function useProductAssociations(
  product: ComputedRef<Schemas["Product"]>,
  options: {
    associationContext: "cross-selling" | "reviews";
  },
): UseProductAssociationsReturn 

Parameters ​

NameTypeDescription
product
ComputedRef<>
options
{
    associationContext: "cross-selling" | "reviews";
  }

Return type ​

See UseProductAssociationsReturn
ts
export type UseProductAssociationsReturn = {
  /**
   * Start loading resources. Search Parameters and HTTP method can be passed.
   *
   */
  loadAssociations(params: {
    method?: "post" | "get";
    searchParams: Schemas["Criteria"];
  }): Promise<void>;
  /**
   * If it's loading - indicator
   */
  isLoading: ComputedRef<boolean>;
  /**
   * Product associations, like CrossSelling[]
   */
  productAssociations: ComputedRef<Schemas["CrossSellingElementCollection"]>;
};

Properties ​

NameTypeDescription
isLoading
ComputedRef<boolean>
If it's loading - indicator
productAssociations
ComputedRef<>
Product associations, like CrossSelling[]

Methods ​

NameTypeDescription
loadAssociations
Promise<void>
Start loading resources. Search Parameters and HTTP method can be passed.

Usage ​

ts
const { loadAssociations, productAssociations } = useProductAssociations(
  product,
  { associationContext: "cross-selling" },
);
if (!productAssociations.value) {
  await loadAssociations();
}
useProductAssociations has loaded