Handle stock_id in OpenProductByBarcode (#1891)

* Handle stock_id in OpenProductByBarcode

* Code formatting

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
Thomas Johanns 2022-05-29 17:05:41 +02:00 committed by GitHub
parent dfdf45fa56
commit dd966fd198
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -583,6 +583,18 @@ class StockApiController extends BaseApiController
try
{
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
if (Grocycode::Validate($args['barcode']))
{
$gc = new Grocycode($args['barcode']);
if ($gc->GetExtraData())
{
$requestBody = $request->getParsedBody();
$requestBody['stock_entry_id'] = $gc->GetExtraData()[0];
$request = $request->withParsedBody($requestBody);
}
}
return $this->OpenProduct($request, $response, $args);
}
catch (\Exception $ex)