按照输入产品ID排序

This commit is contained in:
Edward Yang 2022-12-23 14:55:41 +08:00
parent 06604a3d19
commit 7c3670dd22
1 changed files with 5 additions and 2 deletions

View File

@ -86,8 +86,11 @@ class ProductRepo
});
}
if (isset($data['product_ids'])) {
$builder->whereIn('id', $data['product_ids']);
$productIds = $data['product_ids'] ?? [];
if ($productIds) {
$builder->whereIn('id', $productIds);
$productIds = implode(',', $productIds);
$builder->orderByRaw("FIELD(products.id, {$productIds})");
}
if (isset($data['sku']) || isset($data['model'])) {