diff --git a/app/Endpoint/Api/Http/Controllers/StoreController.php b/app/Endpoint/Api/Http/Controllers/StoreController.php index fb88c4ac..b27c8772 100644 --- a/app/Endpoint/Api/Http/Controllers/StoreController.php +++ b/app/Endpoint/Api/Http/Controllers/StoreController.php @@ -42,11 +42,15 @@ class StoreController extends Controller $input['sort'] = '-id'; } - $spuIds = StoreProductSku::where('store_id', $store->id)->where('status', 1)->pluck('product_spu_id')->toArray(); - $spuIds = array_unique($spuIds); - $spuIds = array_values($spuIds); + // $spuIds = StoreProductSku::where('store_id', $store->id)->where('status', 1)->pluck('product_spu_id')->toArray(); + // $spuIds = array_unique($spuIds); + // $spuIds = array_values($spuIds); - $list = ProductSpu::with(['specs'])->filter($input)->whereIn('id', $spuIds)->simplePaginate(Paginator::resolvePerPage('per_page', 20, 50)); + $list = $store->productSpus() + ->with(['specs']) + ->filter($input) + ->wherePivot('status', 1) + ->simplePaginate(Paginator::resolvePerPage('per_page', 20, 50)); return StoreProductSpuResource::collection($list); }