Feat: Updating Product imports after Boboko restructure

This commit is contained in:
2026-08-27 11:46:33 +03:00
parent 86c645fb36
commit defe1dab12
6 changed files with 14 additions and 31 deletions
+3 -3
View File
@@ -3,8 +3,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Lunar\Models\Collection; use Lunar\Models\Collection;
use Modules\Core\Product\DTOs\ProductFilters; use Modules\Core\Catalog\DTOs\ProductFilters;
use Modules\Core\Product\Services\ProductService; use Modules\Core\Catalog\Services\ProductService;
class CategoryController extends Controller class CategoryController extends Controller
{ {
@@ -18,7 +18,7 @@ public function show(string $locale, Collection $collection)
$page = (int) request('page', 1); $page = (int) request('page', 1);
// Listing/filtering reads from the Meilisearch index via ProductService, // Listing/filtering reads from the Meilisearch index via ProductService,
// not Eloquent — see Modules\Core\Product\Services\ProductService. list() returns a // not Eloquent — see Modules\Core\Catalog\Services\ProductService. list() returns a
// real LengthAwarePaginator of plain arrays (already localized/flattened), // real LengthAwarePaginator of plain arrays (already localized/flattened),
// not Product models. // not Product models.
$products = $this->products->list( $products = $this->products->list(
+2 -3
View File
@@ -4,7 +4,7 @@
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Lunar\Models\Collection; use Lunar\Models\Collection;
use Modules\Core\Product\Services\ProductService; use Modules\Core\Catalog\Services\ProductService;
class ProductController extends Controller class ProductController extends Controller
{ {
@@ -13,11 +13,10 @@ public function __construct(private readonly ProductService $products) {}
public function show(string $locale, int $id) public function show(string $locale, int $id)
{ {
$product = $this->products->getById($id); $product = $this->products->getById($id);
abort_if($product === null, Response::HTTP_NOT_FOUND); abort_if($product === null, Response::HTTP_NOT_FOUND);
$collection = $product['collections'][0] ?? null; $collection = $product['collections'][0] ?? null;
$collectionModel = $collection !== null ? Collection::find($collection) : null; $collectionModel = $collection !== null ? Collection::find($collection['id']) : null;
$variantsData = collect($product['variants']) $variantsData = collect($product['variants'])
->map(fn (array $variant) => [ ->map(fn (array $variant) => [
-16
View File
@@ -16,20 +16,4 @@
'auto_create_customer_for_user' => true, 'auto_create_customer_for_user' => true,
/*
|--------------------------------------------------------------------------
| Product Option Types
|--------------------------------------------------------------------------
|
| Enabled `Modules\Core\Product\Contracts\ProductOptionTypeInterface`
| implementations. An admin picks one per ProductOption from a dropdown
| on the option's own edit form — the selection is stored in
| ProductOption::meta, not tied to the option's handle.
|
*/
'product_option_types' => [
\Modules\Core\Product\OptionTypes\ColorOptionType::class,
],
]; ];
+2 -2
View File
@@ -46,10 +46,10 @@
'indexers' => [ 'indexers' => [
Lunar\Models\Brand::class => Lunar\Search\BrandIndexer::class, Lunar\Models\Brand::class => Lunar\Search\BrandIndexer::class,
Lunar\Models\Collection::class => Lunar\Search\CollectionIndexer::class, Lunar\Models\Collection::class => Modules\Core\Catalog\Services\CollectionIndexer::class,
Lunar\Models\Customer::class => Lunar\Search\CustomerIndexer::class, Lunar\Models\Customer::class => Lunar\Search\CustomerIndexer::class,
Lunar\Models\Order::class => Lunar\Search\OrderIndexer::class, Lunar\Models\Order::class => Lunar\Search\OrderIndexer::class,
Lunar\Models\Product::class => Modules\Core\Product\Services\ProductIndexer::class, Lunar\Models\Product::class => Modules\Core\Catalog\Services\ProductIndexer::class,
Lunar\Models\ProductOption::class => Lunar\Search\ProductOptionIndexer::class, Lunar\Models\ProductOption::class => Lunar\Search\ProductOptionIndexer::class,
], ],
@@ -1,6 +1,6 @@
{{-- $variants: array of Modules\Core\Product\Services\ProductIndexer's mapVariant() {{-- $variants: array of Modules\Core\Catalog\Services\ProductIndexer's mapVariant()
shape (id, options: [{option, value, meta}], ...) — plain arrays, not Eloquent shape (id, options: [{option, value, meta}], ...) — plain arrays, not Eloquent
models, since this is fed from Modules\Core\Product\Services\ProductService. --}} models, since this is fed from Modules\Core\Catalog\Services\ProductService. --}}
@props(['variants', 'option' => null]) @props(['variants', 'option' => null])
<div {{ $attributes }}> <div {{ $attributes }}>
+5 -5
View File
@@ -146,7 +146,7 @@ class="absolute bottom-6 right-8 text-white text-sm"
{{ $product['name'] }} {{ $product['name'] }}
</h1> </h1>
<x-reviews-stars :rating="$product['average_rating'] ?? 0" :count="$product['review_count']" :showCount="true" /> <x-reviews-stars :rating="$product['reviews']['average_rating'] ?? 0" :count="$product['reviews']['count']" :showCount="true" />
@if($product['price'] !== null) @if($product['price'] !== null)
<p class="text-2xl font-bold" data-product-form-target="price"> <p class="text-2xl font-bold" data-product-form-target="price">
@@ -181,7 +181,7 @@ class="absolute bottom-6 right-8 text-white text-sm"
<x-ui.tabs class="mt-16" size="lg" :tabs="[ <x-ui.tabs class="mt-16" size="lg" :tabs="[
['id' => 'description', 'label' => __('storefront.product.description')], ['id' => 'description', 'label' => __('storefront.product.description')],
['id' => 'reviews', 'label' => __('storefront.product.reviews') . ' (' . $product['review_count'] . ')'], ['id' => 'reviews', 'label' => __('storefront.product.reviews') . ' (' . $product['reviews']['count'] . ')'],
]"> ]">
<x-slot name="description"> <x-slot name="description">
<div class="leading-7 [&_p]:mt-4"> <div class="leading-7 [&_p]:mt-4">
@@ -194,9 +194,9 @@ class="absolute bottom-6 right-8 text-white text-sm"
</ul> </ul>
</x-slot> </x-slot>
<x-slot name="reviews"> <x-slot name="reviews">
@if(!empty($product['reviews'])) @if(!empty($product['reviews']['items']))
<div class="mb-10"> <div class="mb-10">
@foreach($product['reviews'] as $review) @foreach($product['reviews']['items'] as $review)
<x-review-card :review="[ <x-review-card :review="[
'rating' => $review['rating'], 'rating' => $review['rating'],
'name' => $review['reviewer_name'], 'name' => $review['reviewer_name'],
@@ -211,7 +211,7 @@ class="absolute bottom-6 right-8 text-white text-sm"
@endif @endif
<h3 class="text-h4 font-bold"> <h3 class="text-h4 font-bold">
{{ $product['review_count'] > 0 ? __('storefront.review.write_new') : __('storefront.review.write_first') }} {{ $product['reviews']['count'] > 0 ? __('storefront.review.write_new') : __('storefront.review.write_first') }}
{{ __('storefront.review.for_product', ['name' => $product['name']]) }} {{ __('storefront.review.for_product', ['name' => $product['name']]) }}
</h3> </h3>