I'm looking for a query to update in bulk using single query instead of using query in loop. I have more than 2000 products and I have to update there stock value. Right now I using loop for each product so its take too much time. Here is my code
foreach($products as $srcProduct){
$product_id = $srcProduct['product_id'];
$onhand = 0;
if(isset($srcProductOnhand[$product_id])){
$onhand = $srcProductOnhand[$product_id];
}
TransferSourceProducts::where(['product_id' => $product_id, 'transfer_id' => $id])
->update(['onhand' =>$onhand]);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire