优化SKU数据量大(5万+)的时候性能问题
This commit is contained in:
parent
28c9e44ef9
commit
5a94945dee
|
|
@ -128,7 +128,7 @@ class ProductRepo
|
|||
$builder->onlyTrashed();
|
||||
}
|
||||
|
||||
$sort = $data['sort'] ?? 'updated_at';
|
||||
$sort = $data['sort'] ?? 'products.updated_at';
|
||||
$order = $data['order'] ?? 'desc';
|
||||
$builder->orderBy($sort, $order);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,9 +29,13 @@ class MenusController extends Controller
|
|||
public function latestProducts()
|
||||
{
|
||||
$products = ProductRepo::getBuilder(['active' => 1])
|
||||
->whereHas('master_sku')
|
||||
->select('products.*')
|
||||
->join('product_skus', function ($query) {
|
||||
$query->on('products.id', '=', 'product_skus.product_id')
|
||||
->where('product_skus.is_default', 1);
|
||||
})
|
||||
->with('master_sku')
|
||||
->with('inCurrentWishlist')
|
||||
->orderByDesc('updated_at')
|
||||
->paginate(40);
|
||||
|
||||
$data = [
|
||||
|
|
|
|||
Loading…
Reference in New Issue