'Grouping an Array by an Object in The Arrays Object -> Vue Storefront
Im new at VueSTorefront and i have a Problem at my Project. I want to Display the Products in the Cart in an Accordion gruped by their type. For this i want to group this Array by their Producttype so i have an Array->Object with the producttype and an Array with Products which have this Producttype. Can someone Help me on this Issue? im struggeling a long time on this issue.
Solution 1:[1]
To resolve this you need to first, manipulate your array into creating a new sorted object, which will sort by the type you want.
Then you need the cart to manipulate a getter to return the same result you want. What I recommend is to "fork" the official getter, or do a merged object with the new getter and the old one.
import { Xgetter } from '@vue-storefront/INTEGRATION;
export default {
...Xgetter,
newGetter: () => ,
};
And finally, you can use your exported getter.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |