Appearance
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 ​
Name | Type | Description |
---|---|---|
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 ​
Name | Type | Description |
---|---|---|
isLoading | ComputedRef<boolean> | If it's loading - indicator |
productAssociations | ComputedRef<> | Product associations, like CrossSelling[] |
Methods ​
Name | Type | Description |
---|---|---|
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();
}