From 211239a5d37fdbf044bca25345b130025e1c898a Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Thu, 19 Nov 2020 18:28:16 +0100 Subject: [PATCH] Fixed `/stock/products/{productId}/entries` endpoint query parameter `include_sub_products` did not work (however) --- services/StockService.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/StockService.php b/services/StockService.php index 2fc88313..b400da0d 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -519,7 +519,7 @@ class StockService extends BaseService public function GetExpiredProducts() { $currentStock = $this->GetCurrentStock(false); - $currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d 23:59:59', strtotime("-1 days")), '<'); + $currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d 23:59:59', strtotime('-1 days')), '<'); $currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'due_type', 2); return $currentStock; @@ -665,11 +665,11 @@ class StockService extends BaseService // In order of next use: // First due first, then first in first out - $sqlWhereProductId = 'product_id = :1'; + $sqlWhereProductId = 'product_id = ' . $productId; if ($allowSubproductSubstitution) { - $sqlWhereProductId = '(product_id IN (SELECT sub_product_id FROM products_resolved WHERE parent_product_id = :1) OR product_id = :1)'; + $sqlWhereProductId = 'product_id IN (SELECT sub_product_id FROM products_resolved WHERE parent_product_id = ' . $productId . ')'; } $sqlWhereAndOpen = 'AND open IN (0, 1)'; @@ -678,7 +678,7 @@ class StockService extends BaseService { $sqlWhereAndOpen = 'AND open = 0'; } - $result = $this->getDatabase()->stock()->where($sqlWhereProductId . ' ' . $sqlWhereAndOpen, $productId); + $result = $this->getDatabase()->stock()->where($sqlWhereProductId . ' ' . $sqlWhereAndOpen); if ($ordered) { return $result->orderBy('best_before_date', 'ASC')->orderBy('purchased_date', 'ASC');