mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
The response of the call '/api/stock' now returns a new attribute ('product') which contains the details of the related product.
This commit is contained in:
committed by
Bernd Bestel
parent
cd522220ce
commit
61a45c030f
@@ -4065,6 +4065,9 @@
|
||||
"is_aggregated_amount": {
|
||||
"type": "boolean",
|
||||
"description": "Indicates wheter this product has sub-products or not / if the fields `amount_aggregated` and `amount_opened_aggregated` are filled"
|
||||
},
|
||||
"product": {
|
||||
"$ref": "#/components/schemas/Product"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@@ -27,7 +27,24 @@ class StockService extends BaseService
|
||||
$sql = 'SELECT * FROM stock_current WHERE best_before_date IS NOT NULL UNION SELECT id, 0, 0, null, 0, 0, 0 FROM ' . $missingProductsView . ' WHERE id NOT IN (SELECT product_id FROM stock_current)';
|
||||
}
|
||||
|
||||
return $this->DatabaseService->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
||||
$current_stock = $this->DatabaseService->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
||||
$stock_array = [];
|
||||
|
||||
foreach ($current_stock as $cur) {
|
||||
$stock_array[$cur->product_id] = $cur;
|
||||
}
|
||||
|
||||
$list_of_product_ids = implode(",", array_keys($stock_array));
|
||||
|
||||
$sql = 'SELECT * FROM products WHERE id in (' . $list_of_product_ids . ')';
|
||||
|
||||
$products = $this->DatabaseService->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
||||
|
||||
foreach ($products as $product) {
|
||||
$stock_array[$product->id]->product = $product;
|
||||
}
|
||||
|
||||
return $stock_array;
|
||||
}
|
||||
|
||||
public function GetCurrentStockLocationContent()
|
||||
|
Reference in New Issue
Block a user