Fix: Correcting shape of indexed products
This commit is contained in:
@@ -72,15 +72,14 @@ needs, listing and detail alike:
|
||||
| Field | Source | Notes |
|
||||
|---|---|---|
|
||||
| `id` | — | Newly marked **filterable** — needed for `getById()`'s `id = "..."` filter; Meilisearch doesn't filter on the primary key by default. |
|
||||
| `collections` | `$product->collections->pluck('id')` | Filterable. Array of collection IDs (as strings) — filtering matches by ID, not slug. |
|
||||
| `collection_names` | `$product->collections` | Display only, not filterable — translated collection names. |
|
||||
| `collections` | `$product->collections` | Array of `{id, name}` — `name` is the translated collection name. Filterable on the nested field `collections.id`, not `collections` itself. |
|
||||
| `slugs` | `$product->urls->pluck('slug')` | Filterable. Every locale's `Url::slug` for the product, so `getBySlug()` resolves purely from the index — no database read. |
|
||||
| `price` | Cheapest variant's base price | Filterable. Float in major units (e.g. `19.99`, not `1999`). Base price only — no customer group, default currency (`Currency::getDefault()`) only. `null` if the product has no priced variant yet, so it's excluded from range filters rather than treated as free. |
|
||||
| `brand` | Already indexed by Lunar's base indexer | Newly marked **filterable** — it existed in the document already, just wasn't usable in a `filter` clause. |
|
||||
| `tags` | `$product->tags->pluck('value')` | Display only. |
|
||||
| `media` | `$product->media` | Full gallery (id/url/thumb per image), not just the single thumbnail Lunar's base indexer sends. |
|
||||
| `variants` | `$product->variants` | Per variant: `id`, `sku`, `stock`, `purchasable`, `options` (option/value names, in the current locale), `prices` (per currency/customer group), `media` (variant-specific images). |
|
||||
| `reviews`, `review_count`, `average_rating` | `Modules\Core\Review\Models\ProductReview` | See "Reviews" below. |
|
||||
| `reviews` | `Modules\Core\Review\Models\ProductReview` | `{items, count, average_rating}` — see "Reviews" below. |
|
||||
|
||||
`name`/`description` (and any other `TranslatedText` attribute) are indexed per-locale — see
|
||||
"Locale resolution" below for how `ProductService` resolves them down to one value per request.
|
||||
@@ -121,11 +120,12 @@ description sourced from `ProductService`'s results must treat it as trusted HTM
|
||||
|
||||
## Reviews
|
||||
|
||||
`Modules\Core\Review\Models\ProductReview` (`product_reviews` table) is indexed per-product as
|
||||
`reviews` (array), plus `review_count` and `average_rating` (rounded to 1 decimal, `null` if the
|
||||
product has no reviews). Only public-safe fields are included — **`reviewer_email` is deliberately
|
||||
excluded**, it's PII with no storefront use. `reply`/`replied_at` (the staff response) are
|
||||
included, since they're meant to be shown alongside the review.
|
||||
`Modules\Core\Review\Models\ProductReview` (`product_reviews` table) is indexed per-product under
|
||||
a single `reviews` key: `{items, count, average_rating}` — `items` is the array of reviews,
|
||||
`average_rating` is rounded to 1 decimal (`null` if the product has no reviews). Only public-safe
|
||||
fields are included on each item — **`reviewer_email` is deliberately excluded**, it's PII with no
|
||||
storefront use. `reply`/`replied_at` (the staff response) are included, since they're meant to be
|
||||
shown alongside the review.
|
||||
|
||||
A review is created/edited independently of its product (a customer submission, a staff reply)
|
||||
— its own save doesn't touch the `Product` row, so the product's own model events never fire.
|
||||
|
||||
Reference in New Issue
Block a user