Do it,
->orderByRaw('gp_products.position - gp_products.updated_at', 'DESC')
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I wanted to show the products only from mentioned by using below query but which is showing only first one.
$productIds = "1,2,3,5,6,8";
$query = GP::table('gp_products')
->select('gp_products.*', 'gp_product_details.*', 'gp_product_status.*')
->join('gp_product_details', 'gp_product_details.product_id', '=', 'gp_products.product_id')
->leftJoin('gp_product_status', 'gp_product_status.product_id', '=', 'gp_products.product_id')
->whereIn('gp_products.product_id', [$productIds])
->where([
['gp_product_details.locale', '=', 'en_US'],
['gp_products.type', '=', 'dynamic'],
['gp_products.status', '=', 1]
])
->orderByRaw('gp_products.position - gp_products.updated_at DESC')
->get();
return $query;
Then do it,
$productIds = [1,2,3,5,6,8];
After that,
->whereIn('gp_products.product_id', $productIds)
Please or to participate in this conversation.