mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
Fixed external barcode lookup (plugin) add product handling related to barcodes (fixes #1568)
This commit is contained in:
@@ -510,10 +510,16 @@ class StockService extends BaseService
|
|||||||
if ($addFoundProduct === true)
|
if ($addFoundProduct === true)
|
||||||
{
|
{
|
||||||
// Add product to database and include new product id in output
|
// Add product to database and include new product id in output
|
||||||
$newRow = $this->getDatabase()->products()->createRow($pluginOutput);
|
$productData = $pluginOutput;
|
||||||
$newRow->save();
|
unset($productData['barcode']);
|
||||||
|
$newProductRow = $this->getDatabase()->products()->createRow($productData);
|
||||||
|
$newProductRow->save();
|
||||||
|
$this->getDatabase()->product_barcodes()->createRow([
|
||||||
|
'product_id' => $newProductRow->id,
|
||||||
|
'barcode' => $pluginOutput['barcode']
|
||||||
|
])->save();
|
||||||
|
|
||||||
$pluginOutput['id'] = $newRow->id;
|
$pluginOutput['id'] = $newProductRow->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user