@shopbite-de/storefront 1.31.1 → 1.31.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nuxtrc +1 -1
- package/CLAUDE.md +1 -1
- package/app/composables/useRestaurantSchema.ts +1 -0
- package/app/utils/schema.ts +5 -0
- package/docs/notes/2026-10-07-issue-434-property-group-projection.md +27 -0
- package/docs/notes/2026-10-07-listing-payload.md +38 -0
- package/docs/notes/2026-10-07-nuxt-4.6-inline-error-rendering.md +31 -0
- package/nuxt.config.ts +5 -0
- package/package.json +1 -1
- package/server/api/listing/[categoryId].get.ts +7 -11
- package/server/api/product/[productId].get.ts +4 -2
- package/server/api/product/variant.get.ts +1 -2
- package/server/api/search.get.ts +7 -12
- package/server/routes/llms.txt.ts +1 -0
- package/server/utils/llmsTxt.ts +5 -0
- package/test/unit/llmsTxt.spec.ts +23 -2
- package/test/unit/schema.spec.ts +16 -0
- package/app/components/Product/Category.vue +0 -160
package/.nuxtrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
setups.@nuxt/test-utils="4.3.
|
|
1
|
+
setups.@nuxt/test-utils="4.3.3"
|
package/CLAUDE.md
CHANGED
|
@@ -138,7 +138,7 @@ Pages without content throw `createNotFoundError()` (`app/utils/notFound.ts`): f
|
|
|
138
138
|
- `@nuxtjs/sitemap` must stay before `@nuxt/content` in `modules`; content collections need the `sitemap` schema field to appear in the sitemap.
|
|
139
139
|
- The home page FAQ (`faq` in `content/index.yml`, `Home/Faq.vue`, #404) uses native `<details>`, not `UAccordion`: Reka unmounts closed panels, and the answers must be in the SSR HTML. The same items feed the `FAQPage` JSON-LD and `/llms.txt`.
|
|
140
140
|
- `server/plugins/ai-crawlers.ts` adds two named robots.txt groups via the `robots:config` hook (#403): AI search/assistant bots and AI training bots (lists with sources in `server/utils/aiCrawlers.ts`), toggled by `runtimeConfig.aiCrawlers.search`/`.training`. A crawler matching a named group ignores `*`, so allowed groups repeat the `robots.disallow` paths.
|
|
141
|
-
- Shop contact data (NAP) lives in `runtimeConfig.public.site` (`address.*`, `telephone`, `googleBusinessProfileUrl`) and is rendered by `components/Footer/Contact.vue`. `useBusinessHours`/`useHolidays` use `immediate: false` (app.vue loads them on mount); a component that needs them in the SSR HTML calls `onServerPrefetch(() => refresh())`. In the browser both requests are retried twice (`withRetries`); `useOpeningHoursData` gives components the combined loading/failed state and `retry()`, and reports a failure only after mounting (a failed server prefetch would otherwise break hydration, #355). Anything that depends on the current time (open/closed status, "today") is computed after mounting: `useStoreStatus` starts its clock in `onMounted`, because the home page prefetches the hours on the server and the server's clock and time zone differ from the visitor's (hydration mismatch, #365).
|
|
141
|
+
- Shop contact data (NAP) lives in `runtimeConfig.public.site` (`address.*`, `telephone`, `googleBusinessProfileUrl`; `alternateNames` lists other names the shop is listed under, for the Restaurant schema `alternateName` and `/llms.txt`) and is rendered by `components/Footer/Contact.vue`. `useBusinessHours`/`useHolidays` use `immediate: false` (app.vue loads them on mount); a component that needs them in the SSR HTML calls `onServerPrefetch(() => refresh())`. In the browser both requests are retried twice (`withRetries`); `useOpeningHoursData` gives components the combined loading/failed state and `retry()`, and reports a failure only after mounting (a failed server prefetch would otherwise break hydration, #355). Anything that depends on the current time (open/closed status, "today") is computed after mounting: `useStoreStatus` starts its clock in `onMounted`, because the home page prefetches the hours on the server and the server's clock and time zone differ from the visitor's (hydration mismatch, #365).
|
|
142
142
|
|
|
143
143
|
### Testing setup
|
|
144
144
|
|
package/app/utils/schema.ts
CHANGED
|
@@ -26,6 +26,8 @@ type HolidayLike = {
|
|
|
26
26
|
|
|
27
27
|
export type SiteInfo = {
|
|
28
28
|
name: string;
|
|
29
|
+
/** Other names the shop is listed under, e.g. "Alte Schmiede". */
|
|
30
|
+
alternateNames?: string[];
|
|
29
31
|
url: string;
|
|
30
32
|
description?: string;
|
|
31
33
|
image?: string;
|
|
@@ -199,6 +201,9 @@ export function buildRestaurantSchema(input: {
|
|
|
199
201
|
"@type": "Restaurant",
|
|
200
202
|
"@id": `${site.url}#restaurant`,
|
|
201
203
|
name: site.name,
|
|
204
|
+
alternateName: site.alternateNames?.length
|
|
205
|
+
? site.alternateNames
|
|
206
|
+
: undefined,
|
|
202
207
|
description: site.description,
|
|
203
208
|
url: site.url,
|
|
204
209
|
image: site.image,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# #434: property groups projected in product, variant and search routes
|
|
2
|
+
|
|
3
|
+
As of 2026-10-07, branch `fix/issue-434-property-group-projection`. Follow-up of the listing fix in #435 (`docs/notes/2026-10-07-listing-payload.md`).
|
|
4
|
+
|
|
5
|
+
## Change
|
|
6
|
+
|
|
7
|
+
All Store API projections used the key `property` for property groups. The entity is `property_group`, so Shopware returned the groups with every field. `product_option` is no entity either (options are `property_group_option`), so that key had no effect and is removed.
|
|
8
|
+
|
|
9
|
+
- `server/api/product/[productId].get.ts` and `server/api/product/variant.get.ts`: `property_group: ["id", "name", "translated", "options"]`. Options keep `group`: the configurator reads `option.group.id`, the ingredient selection `option.group.name`.
|
|
10
|
+
- `server/api/search.get.ts`: same projection as the listing (#435), because the search page renders the same cards: `property_group` with `displayType`, options without `group`, no `properties`/`propertyIds`.
|
|
11
|
+
- `app/components/Product/Category.vue` deleted: it was rendered nowhere (only recursively by itself), neither in the storefront nor in La Fattoria or the quickstart repo.
|
|
12
|
+
|
|
13
|
+
## Verification (demo backend, `main` build against branch build)
|
|
14
|
+
|
|
15
|
+
| Route | Requests | Size before → after | Differences |
|
|
16
|
+
| --- | --- | --- | --- |
|
|
17
|
+
| `/api/product/[productId]` | all 63 listing products | 294 → 178 KB | none in the fields read (see below) |
|
|
18
|
+
| `/api/product/variant` | all 66 option combinations of the 21 variant products | 154 → 95 KB | none |
|
|
19
|
+
| `/api/search` | `pizza`, `salami`, `vegan`, `cola` | `pizza` 113 → 35 KB | cards and filters equal |
|
|
20
|
+
|
|
21
|
+
Compared fields: name, description, price, `optionIds`, options and properties with their group id and name, `sortedProperties`, cover, categories, configurator settings, children and the `configurator` groups.
|
|
22
|
+
|
|
23
|
+
For 5 parent products the route returned a different variant in the two builds. Shopware picks the variant of a parent without a main variant at random on every request (five direct Store API requests for the same parent gave four different variants, with either include key), and the route caches the first answer for 24 hours. The configurator of these parents and both variants of each were compared by variant id: equal.
|
|
24
|
+
|
|
25
|
+
Browser (desktop, quick view via deep link): for `LF-20` (ingredients) and `LF-112` (variants), drawer text, variant switch, URL (`?produkt=LF-112-reis`, `?ohne=Eisbergsalat`) and the cart request (`"label":"Beilagensalat -Eisbergsalat"`) are identical in both builds. Both builds log "Hydration completed but contains mismatches" on a deep link to a category page (#425).
|
|
26
|
+
|
|
27
|
+
Typecheck, ESLint, Prettier, unit tests (348) pass.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Listing payload: property groups were not projected
|
|
2
|
+
|
|
3
|
+
As of 2026-10-07, branch `feature/payload-size`. Prompted by the Nuxt 4.6 features for lighter payloads (`useAsyncData` `serialize: false`, a dev warning above 100 kB payload).
|
|
4
|
+
|
|
5
|
+
## Payload per page (demo backend, before)
|
|
6
|
+
|
|
7
|
+
| Page | HTML | `__NUXT_DATA__` | Largest key |
|
|
8
|
+
| --- | --- | --- | --- |
|
|
9
|
+
| `/` | 151 KB | 44 KB | `top-sellers` 15 KB |
|
|
10
|
+
| `/Speisekarte/` (63 products) | 463 KB | 224 KB | `listing-<id>` 219 KB |
|
|
11
|
+
| `/impressum` | 69 KB | 22 KB | `sessionContext` 8 KB |
|
|
12
|
+
|
|
13
|
+
Only the menu page was over the 100 kB threshold. `serialize: false` does not fit there: the product cards hydrate on scroll (`hydrateWhenVisible`) and need the listing data in the browser. Without it in the payload, the browser would fetch the listing again.
|
|
14
|
+
|
|
15
|
+
## Cause
|
|
16
|
+
|
|
17
|
+
`server/api/listing/[categoryId].get.ts` projected the property groups under the key `property`. The entity is `property_group` (`useTopSellers` already used the right name), so the groups came back with every field (`createdAt`, `updatedAt`, `sortingType`, `filterable`, …). Each option also carried its whole group once more. On top of that the product projection included `properties` (all options with their group) next to `sortedProperties` (the same options, grouped):
|
|
18
|
+
|
|
19
|
+
- `sortedProperties` 124 KB, `properties` 95 KB of 284 KB elements.
|
|
20
|
+
|
|
21
|
+
The card only reads `sortedProperties` (group `translated.name`, `displayType`, option `translated.name`, `media.url`). The quick view loads its product separately from `/api/product/[productId]`.
|
|
22
|
+
|
|
23
|
+
## Change
|
|
24
|
+
|
|
25
|
+
- `property_group: ["id", "name", "translated", "displayType", "options"]` instead of `property`.
|
|
26
|
+
- `property_group_option` without `group`.
|
|
27
|
+
- `properties` and `propertyIds` dropped from the product projection.
|
|
28
|
+
|
|
29
|
+
Result for `/Speisekarte/`: listing response 295 → 103 KB, payload 224 → 103 KB, HTML 463 → 342 KB. The rendered HTML of the page is unchanged (diff without scripts and asset hashes is empty), and so are the card data (`sortedProperties` as the card reads it) and the filter aggregations for all 63 products. Smoke test (menu, quick view, add to cart, cart, deep link) shows no console errors or hydration warnings.
|
|
30
|
+
|
|
31
|
+
## Not changed
|
|
32
|
+
|
|
33
|
+
- `server/api/product/[productId].get.ts` and `components/Product/Category.vue` use the same wrong key `property`. The product route also serves the configurator and the ingredient selection (`option.group.name`), so a projection there needs its own check of every field the quick view reads.
|
|
34
|
+
- `calculatedPrice` (21 KB for 63 products, mostly `calculatedTaxes`/`taxRules`) is left as it is.
|
|
35
|
+
|
|
36
|
+
## `useAsyncData` addons (Nuxt 4.6): not used
|
|
37
|
+
|
|
38
|
+
`createUseAsyncData` with an addon could replace `withRetries` (`app/utils/retry.ts`) in `useBusinessHours` and `useHolidays`. It would need a custom composable factory and an addon definition to replace two five-line call sites of a plain, unit-tested helper, so the helper stays.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Nuxt 4.6 `experimental.inlineErrorRendering`: no gain, not enabled
|
|
2
|
+
|
|
3
|
+
As of 2026-10-07, after the update to Nuxt 4.6.0 (#424). Measured on a throwaway branch, not merged.
|
|
4
|
+
|
|
5
|
+
## What the option does
|
|
6
|
+
|
|
7
|
+
With `experimental.inlineErrorRendering: true` (default from `compatibilityVersion: 5`), a failed server render shows `error.vue` in the same request. Without it, Nuxt passes the error to Nitro, which renders the error page through an internal request to `/__nuxt_error`. The hope was cheaper 404s for scanner traffic (#363).
|
|
8
|
+
|
|
9
|
+
## Measurement
|
|
10
|
+
|
|
11
|
+
Two production builds (with and without the flag) against the demo backend (`shopware.shopbite.de`), 400 requests per run with 4 parallel, server CPU time read from `/proc/<pid>/stat`:
|
|
12
|
+
|
|
13
|
+
| | without | with |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| `/wp-login.php`, 4 runs | 48 ms CPU/request | 59 ms |
|
|
16
|
+
| `/gibtsnicht` (unknown category), 3 runs | 52 ms | 54 ms |
|
|
17
|
+
| `/impressum` (control, flag has no effect) | 42 ms | 52 ms |
|
|
18
|
+
|
|
19
|
+
The runs scatter by 10–25 ms, and the control page differs by 10 ms although the flag does not touch it. No saving is visible. Response times are dominated by the Store API requests and say nothing either way.
|
|
20
|
+
|
|
21
|
+
## Side effects on 404 responses
|
|
22
|
+
|
|
23
|
+
- `cache-control: no-cache` and `vary: accept, sec-fetch-mode` are missing (they come from Nuxt's Nitro error handler). Without `cache-control`, proxies and CDNs may cache a 404 heuristically.
|
|
24
|
+
- The 404 page gets an extra `<meta name="robots" content="index, follow, …">`.
|
|
25
|
+
- Every 404 still logs an error object to the server log, only in a different format. The flag does not fix #363.
|
|
26
|
+
|
|
27
|
+
Status codes, page titles and regular pages are unchanged.
|
|
28
|
+
|
|
29
|
+
## Decision
|
|
30
|
+
|
|
31
|
+
Not enabled. Check again when moving to `compatibilityVersion: 5` or Nuxt 5, where it becomes the default: in particular whether 404 responses then carry a `cache-control` header again.
|
package/nuxt.config.ts
CHANGED
|
@@ -109,6 +109,11 @@ export default defineNuxtConfig({
|
|
|
109
109
|
},
|
|
110
110
|
telephone: "",
|
|
111
111
|
googleBusinessProfileUrl: "",
|
|
112
|
+
// Other names the shop is known by on maps and directories, comma-
|
|
113
|
+
// separated ("La Fattoria / Alte Schmiede, Alte Schmiede"), so search
|
|
114
|
+
// engines and AI assistants match them to this shop. Restaurant
|
|
115
|
+
// schema `alternateName` and /llms.txt.
|
|
116
|
+
alternateNames: "",
|
|
112
117
|
// Restaurant schema only, e.g. "€€" (#272).
|
|
113
118
|
priceRange: "",
|
|
114
119
|
// Restaurant schema only (#401): comma-separated delivery areas
|
package/package.json
CHANGED
|
@@ -11,8 +11,9 @@ const BASE_CRITERIA = {
|
|
|
11
11
|
"description",
|
|
12
12
|
"calculatedPrice",
|
|
13
13
|
"translated",
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// The card reads the properties grouped (ingredients, diets, kitchen);
|
|
15
|
+
// `properties` would repeat every option with its group. The quick view
|
|
16
|
+
// loads its own product (/api/product/[productId]).
|
|
16
17
|
"sortedProperties",
|
|
17
18
|
"cover",
|
|
18
19
|
// "Ausverkauft" on the card (#325).
|
|
@@ -21,15 +22,10 @@ const BASE_CRITERIA = {
|
|
|
21
22
|
"seoUrls",
|
|
22
23
|
],
|
|
23
24
|
seo_url: ["seoPathInfo", "isCanonical"],
|
|
24
|
-
property
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"translated",
|
|
29
|
-
"group",
|
|
30
|
-
"media",
|
|
31
|
-
"mediaId",
|
|
32
|
-
],
|
|
25
|
+
// The entity is `property_group`: under `property` the groups came back
|
|
26
|
+
// with every field, nested once more in each option.
|
|
27
|
+
property_group: ["id", "name", "translated", "displayType", "options"],
|
|
28
|
+
property_group_option: ["id", "name", "translated", "media", "mediaId"],
|
|
33
29
|
product_option: ["id", "groupId", "name", "translated", "group"],
|
|
34
30
|
...MEDIA_INCLUDES,
|
|
35
31
|
},
|
|
@@ -22,10 +22,12 @@ const criteria = {
|
|
|
22
22
|
"sortedProperties",
|
|
23
23
|
"cover",
|
|
24
24
|
],
|
|
25
|
-
property
|
|
25
|
+
// The entity is `property_group`: under `property` the groups came back
|
|
26
|
+
// with every field. Options keep their group for the configurator and
|
|
27
|
+
// the ingredient selection (`option.group.name`).
|
|
28
|
+
property_group: ["id", "name", "translated", "options"],
|
|
26
29
|
property_group_option: ["id", "name", "translated", "group"],
|
|
27
30
|
product_configurator_setting: ["id", "optionId", "option", "productId"],
|
|
28
|
-
product_option: ["id", "groupId", "name", "translated", "group"],
|
|
29
31
|
category: ["id", "name", "translated"],
|
|
30
32
|
...MEDIA_INCLUDES,
|
|
31
33
|
},
|
|
@@ -73,8 +73,7 @@ export default defineCachedEventHandler(
|
|
|
73
73
|
"properties",
|
|
74
74
|
"calculatedPrice",
|
|
75
75
|
],
|
|
76
|
-
|
|
77
|
-
property: ["id", "name", "translated", "options"],
|
|
76
|
+
property_group: ["id", "name", "translated", "options"],
|
|
78
77
|
property_group_option: ["id", "name", "translated", "group"],
|
|
79
78
|
},
|
|
80
79
|
associations: {
|
package/server/api/search.get.ts
CHANGED
|
@@ -11,23 +11,18 @@ const BASE_CRITERIA = {
|
|
|
11
11
|
"description",
|
|
12
12
|
"calculatedPrice",
|
|
13
13
|
"translated",
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// The card reads the properties grouped (ingredients, diets, kitchen);
|
|
15
|
+
// `properties` would repeat every option with its group. The quick view
|
|
16
|
+
// loads its own product (/api/product/[productId]).
|
|
16
17
|
"sortedProperties",
|
|
17
18
|
"cover",
|
|
18
19
|
// "Ausverkauft" on the card (#325).
|
|
19
20
|
"available",
|
|
20
21
|
],
|
|
21
|
-
property
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"translated",
|
|
26
|
-
"group",
|
|
27
|
-
"media",
|
|
28
|
-
"mediaId",
|
|
29
|
-
],
|
|
30
|
-
product_option: ["id", "groupId", "name", "translated", "group"],
|
|
22
|
+
// The entity is `property_group`: under `property` the groups came back
|
|
23
|
+
// with every field, nested once more in each option.
|
|
24
|
+
property_group: ["id", "name", "translated", "displayType", "options"],
|
|
25
|
+
property_group_option: ["id", "name", "translated", "media", "mediaId"],
|
|
31
26
|
},
|
|
32
27
|
associations: {
|
|
33
28
|
cover: {
|
package/server/utils/llmsTxt.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type LlmsMenuSection = {
|
|
|
24
24
|
|
|
25
25
|
export type LlmsTxtInput = {
|
|
26
26
|
name: string;
|
|
27
|
+
/** Other names the shop is listed under on maps and directories. */
|
|
28
|
+
alternateNames?: string[];
|
|
27
29
|
description?: string;
|
|
28
30
|
url: string;
|
|
29
31
|
cuisine?: string;
|
|
@@ -125,6 +127,9 @@ export function buildLlmsTxt(input: LlmsTxtInput): string {
|
|
|
125
127
|
.join(" ");
|
|
126
128
|
|
|
127
129
|
const contact = [
|
|
130
|
+
input.alternateNames?.length
|
|
131
|
+
? `- Auch bekannt als: ${input.alternateNames.join(", ")}`
|
|
132
|
+
: undefined,
|
|
128
133
|
input.address?.street || input.address?.postalCode || city
|
|
129
134
|
? `- Adresse: ${[
|
|
130
135
|
input.address?.street,
|
|
@@ -135,9 +135,30 @@ Nach Obertshausen und Lämmerspiel.
|
|
|
135
135
|
`);
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
+
it("names other names of the shop under Kontakt", () => {
|
|
139
|
+
expect(
|
|
140
|
+
buildLlmsTxt({
|
|
141
|
+
name: "Pizzeria La Fattoria",
|
|
142
|
+
alternateNames: ["La Fattoria / Alte Schmiede", "Alte Schmiede"],
|
|
143
|
+
url: "https://www.pizzeria-lafattoria.de",
|
|
144
|
+
now,
|
|
145
|
+
}),
|
|
146
|
+
).toContain(`## Kontakt
|
|
147
|
+
|
|
148
|
+
- Auch bekannt als: La Fattoria / Alte Schmiede, Alte Schmiede
|
|
149
|
+
- Website: https://www.pizzeria-lafattoria.de
|
|
150
|
+
`);
|
|
151
|
+
});
|
|
152
|
+
|
|
138
153
|
it("leaves out what is not configured", () => {
|
|
139
|
-
expect(
|
|
140
|
-
|
|
154
|
+
expect(
|
|
155
|
+
buildLlmsTxt({
|
|
156
|
+
name: "ShopBite",
|
|
157
|
+
alternateNames: [],
|
|
158
|
+
url: "https://example.com",
|
|
159
|
+
now,
|
|
160
|
+
}),
|
|
161
|
+
).toBe(`# ShopBite
|
|
141
162
|
|
|
142
163
|
> ShopBite.
|
|
143
164
|
|
package/test/unit/schema.spec.ts
CHANGED
|
@@ -243,11 +243,27 @@ describe("buildRestaurantSchema", () => {
|
|
|
243
243
|
});
|
|
244
244
|
});
|
|
245
245
|
|
|
246
|
+
it("lists other names of the shop as alternateName", () => {
|
|
247
|
+
const schema = buildRestaurantSchema({
|
|
248
|
+
site: {
|
|
249
|
+
name: "Pizzeria La Fattoria",
|
|
250
|
+
url: "https://www.pizzeria-lafattoria.de",
|
|
251
|
+
alternateNames: ["La Fattoria / Alte Schmiede", "Alte Schmiede"],
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
expect(schema.alternateName).toEqual([
|
|
256
|
+
"La Fattoria / Alte Schmiede",
|
|
257
|
+
"Alte Schmiede",
|
|
258
|
+
]);
|
|
259
|
+
});
|
|
260
|
+
|
|
246
261
|
it("leaves empty values out", () => {
|
|
247
262
|
const schema = buildRestaurantSchema({
|
|
248
263
|
site: {
|
|
249
264
|
name: "ShopBite",
|
|
250
265
|
url: "https://example.com",
|
|
266
|
+
alternateNames: [],
|
|
251
267
|
telephone: "",
|
|
252
268
|
address: { street: "", postalCode: "", city: "", country: "DE" },
|
|
253
269
|
},
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { Schemas } from "#shopware";
|
|
3
|
-
import ProductCard from "~/components/Product/Card.vue";
|
|
4
|
-
|
|
5
|
-
const props = defineProps({
|
|
6
|
-
category: {
|
|
7
|
-
type: Object as () => Schemas["Category"],
|
|
8
|
-
required: true,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const category = toRef(props.category);
|
|
13
|
-
const { apiClient } = useShopwareContext();
|
|
14
|
-
const categoryProducts = ref<Schemas["Product"][]>([]);
|
|
15
|
-
const quickView = useProductQuickView(categoryProducts);
|
|
16
|
-
const isLoading = ref(true);
|
|
17
|
-
|
|
18
|
-
const fetchCategoryProducts = async () => {
|
|
19
|
-
isLoading.value = true;
|
|
20
|
-
try {
|
|
21
|
-
const { data } = await apiClient.invoke("readProduct post /product", {
|
|
22
|
-
body: {
|
|
23
|
-
filter: [
|
|
24
|
-
{
|
|
25
|
-
type: "equals",
|
|
26
|
-
field: "categoryTree",
|
|
27
|
-
value: category.value.id,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
type: "equals",
|
|
31
|
-
field: "parentId",
|
|
32
|
-
value: null,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
includes: {
|
|
36
|
-
product: [
|
|
37
|
-
"id",
|
|
38
|
-
"productNumber",
|
|
39
|
-
"name",
|
|
40
|
-
"description",
|
|
41
|
-
"calculatedPrice",
|
|
42
|
-
"translated",
|
|
43
|
-
"categories",
|
|
44
|
-
"properties",
|
|
45
|
-
"propertyIds",
|
|
46
|
-
"options",
|
|
47
|
-
"optionIds",
|
|
48
|
-
"configuratorSettings",
|
|
49
|
-
"children",
|
|
50
|
-
"parentId",
|
|
51
|
-
"sortedProperties",
|
|
52
|
-
"cover",
|
|
53
|
-
],
|
|
54
|
-
property: ["id", "name", "translated", "options"],
|
|
55
|
-
property_group_option: ["id", "name", "translated", "group"],
|
|
56
|
-
product_configurator_setting: [
|
|
57
|
-
"id",
|
|
58
|
-
"optionId",
|
|
59
|
-
"option",
|
|
60
|
-
"productId",
|
|
61
|
-
],
|
|
62
|
-
product_option: ["id", "groupId", "name", "translated", "group"],
|
|
63
|
-
},
|
|
64
|
-
sort: [
|
|
65
|
-
{
|
|
66
|
-
field: "productNumber",
|
|
67
|
-
order: "ASC",
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
associations: {
|
|
71
|
-
cover: {
|
|
72
|
-
associations: {
|
|
73
|
-
media: {},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
categories: {},
|
|
77
|
-
properties: {
|
|
78
|
-
associations: {
|
|
79
|
-
group: {},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
options: {
|
|
83
|
-
associations: {
|
|
84
|
-
group: {},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
configuratorSettings: {
|
|
88
|
-
associations: {
|
|
89
|
-
option: {
|
|
90
|
-
associations: {
|
|
91
|
-
group: {},
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
children: {
|
|
97
|
-
associations: {
|
|
98
|
-
properties: {
|
|
99
|
-
associations: {
|
|
100
|
-
group: {},
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
options: {
|
|
104
|
-
associations: {
|
|
105
|
-
group: {},
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
if (data?.elements) {
|
|
115
|
-
categoryProducts.value = data.elements;
|
|
116
|
-
}
|
|
117
|
-
} catch (error) {
|
|
118
|
-
console.error(`[category-products][${category.value.id}]`, error);
|
|
119
|
-
} finally {
|
|
120
|
-
isLoading.value = false;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// Fetch products when the component is mounted
|
|
125
|
-
onMounted(() => {
|
|
126
|
-
fetchCategoryProducts();
|
|
127
|
-
});
|
|
128
|
-
</script>
|
|
129
|
-
<template>
|
|
130
|
-
<div
|
|
131
|
-
v-if="!isLoading && categoryProducts.length > 0"
|
|
132
|
-
:id="category.name ?? ''"
|
|
133
|
-
class="flex flex-col"
|
|
134
|
-
>
|
|
135
|
-
<CategoryHeader :category="category" />
|
|
136
|
-
<div v-if="category.childCount > 0" class="grid grid-cols-1 gap-4">
|
|
137
|
-
<ProductCategory
|
|
138
|
-
v-for="child in category.children"
|
|
139
|
-
:key="child.id"
|
|
140
|
-
:category="child"
|
|
141
|
-
/>
|
|
142
|
-
</div>
|
|
143
|
-
<div v-else class="grid grid-cols-1 gap-4 xl:grid-cols-2">
|
|
144
|
-
<ProductCard
|
|
145
|
-
v-for="product in categoryProducts"
|
|
146
|
-
:key="product.id"
|
|
147
|
-
:product="product"
|
|
148
|
-
:with-favorite-button="true"
|
|
149
|
-
:selectable="true"
|
|
150
|
-
@select="quickView.show"
|
|
151
|
-
/>
|
|
152
|
-
</div>
|
|
153
|
-
<LazyProductQuickView
|
|
154
|
-
v-if="quickView.mounted.value"
|
|
155
|
-
v-model:open="quickView.open.value"
|
|
156
|
-
:product="quickView.product.value"
|
|
157
|
-
/>
|
|
158
|
-
</div>
|
|
159
|
-
<div v-else-if="isLoading" class="flex flex-col" />
|
|
160
|
-
</template>
|