optimization getListByProductIds
This commit is contained in:
parent
af6f079b43
commit
56f17772ca
|
|
@ -19,6 +19,7 @@ use Beike\Models\ProductCategory;
|
||||||
use Beike\Models\ProductDescription;
|
use Beike\Models\ProductDescription;
|
||||||
use Beike\Models\ProductRelation;
|
use Beike\Models\ProductRelation;
|
||||||
use Beike\Models\ProductSku;
|
use Beike\Models\ProductSku;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Beike\Shop\Http\Resources\ProductSimple;
|
use Beike\Shop\Http\Resources\ProductSimple;
|
||||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
@ -365,6 +366,7 @@ class ProductRepo
|
||||||
$products = Product::query()
|
$products = Product::query()
|
||||||
->with(['description'])
|
->with(['description'])
|
||||||
->whereIn('id', $productIds)
|
->whereIn('id', $productIds)
|
||||||
|
->orderByRaw(DB::raw('FIELD(id, ' . implode(',', $productIds) . ')'))
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $products;
|
return $products;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue