frontends icon indicating copy to clipboard operation
frontends copied to clipboard

[BUG] get all variants for single product by useCategorySearch()

Open andre9x opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

the only information i got is from the current variant

Expected Behavior

i want all variants within a single product on the listing page (i have to show all variants by hovering the current product)

Steps To Reproduce

  1. fetching data in FrontendNavigationPage.vue
const categoryResponse = await search(foreignKey.value, {
  withCmsAssociations: true,
  query: {
    ...route.query,
  },
});
  1. iterating trough elements in CmsElementProductListing.vue
  2. trying to access all variants for a single product ProductCard.vue
  3. within options there is just the current one (array with one item only), children is null, parent is null ... image
  4. tried to get it by associations but still one entry in options and parent / children is null. image

What am I doing wrong?

Environment

No response

Anything else?

No response

andre9x avatar Aug 20 '24 12:08 andre9x

Due to performance reasons, showing the available options on product hover is a great case for async loading - and would be enough if the API responds really quick. Then I would try to use useProductSearch with combination of useProductConfigurator / useProduct to relatively easy extract the possible options.

The alternative option is to use the aggregations and take the possible options with all the listing elements (products) in just one request. @BrocksiNet had shown an example how to approach this: https://www.brocksi.net/blog/variants-selection-multi-page-or-single-page/#listing-with-all-options-for-products. that might br the case for useCategorySearch which also allows to use a search criteria (including aggregations).

mkucmus avatar Aug 21 '24 09:08 mkucmus

We also have an internal Issue with that NEXT-36467.

BrocksiNet avatar Oct 02 '24 08:10 BrocksiNet

The internal issue was closed. This is already working.

BrocksiNet avatar Feb 19 '25 16:02 BrocksiNet