Appearance
useProductAssociations
Definition
Get product association entity.
Basic usage
ts
const {
isLoading,
productAssociations,
loadAssociations
} = useProductAssociations(product, options);
Signature
ts
export function useProductAssociations(
product: ComputedRef<Product>,
options: {
associationContext: "cross-selling" | "reviews";
},
): UseProductAssociationsReturn
Parameters
Name | Type | Description |
---|---|---|
product | ComputedRef<Product> | |
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: ShopwareSearchParams;
}): Promise<void>;
/**
* If it's loading - indicator
*/
isLoading: ComputedRef<boolean>;
/**
* Product associations, like CrossSelling[]
*/
productAssociations: ComputedRef<CrossSelling[]>;
};
Properties
Name | Type | Description |
---|---|---|
isLoading | ComputedRef<boolean> | If it's loading - indicator |
productAssociations | ComputedRef<Array<CrossSelling>> | 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();
}