Added a filter option to only show currently out-of-stock products on /products (closes #2192)

This commit is contained in:
Bernd Bestel
2023-04-13 20:28:28 +02:00
parent 2bce428339
commit 16011b91c6
6 changed files with 43 additions and 17 deletions

View File

@@ -243,6 +243,10 @@ class StockController extends BaseController
{
$products = $products->where('id IN (SELECT product_id from stock_current WHERE amount_aggregated > 0)');
}
if (isset($request->getQueryParams()['only_out_of_stock']))
{
$products = $products->where('id NOT IN (SELECT product_id from stock_current WHERE amount_aggregated > 0)');
}
$products = $products->orderBy('name', 'COLLATE NOCASE');