shopware / frontends

Shopware Frontends is a framework for building custom, headless storefronts with Shopware 6.
https://frontends.shopware.com
MIT License
176 stars 49 forks source link

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

Open andre9x opened 2 months ago

andre9x commented 2 months ago

Is there an existing issue for this?

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,
    },
    });
  2. iterating trough elements in CmsElementProductListing.vue
  3. trying to access all variants for a single product ProductCard.vue
  4. within options there is just the current one (array with one item only), children is null, parent is null ... image
  5. 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

mkucmus commented 2 months ago

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).

BrocksiNet commented 1 month ago

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