Skip to content

Commit

Permalink
if the product exists on import update it
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Jan 18, 2024
1 parent 80ad58e commit ec3b7a3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Http/Controllers/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public function importStore(Request $request){
$collection = Excel::toArray(new ImportProducts(), $request->file('file'));
unset($collection[0][0]);
foreach ($collection[0] as $item){
$checkIfProductExists = Product::where('sku', $item[1])->where('barcode', $item[2])->first();
$checkIfProductExists = Product::where('sku', $item[1])->orWhere('barcode', $item[2])->first();
if($checkIfProductExists){
$checkIfProductExists->name = $item[0]??null;
$checkIfProductExists->slug = Str::of($item[0])->slug('-')??null;
Expand Down

0 comments on commit ec3b7a3

Please sign in to comment.