From c8dfb5b12a40e7d380b41de13e27292602098e33 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Sat, 27 Apr 2024 17:25:14 +0300 Subject: [PATCH] add products item list --- .../v1/controllers/ProductController.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 erp24/api3/modules/v1/controllers/ProductController.php diff --git a/erp24/api3/modules/v1/controllers/ProductController.php b/erp24/api3/modules/v1/controllers/ProductController.php new file mode 100644 index 0000000..e858c89 --- /dev/null +++ b/erp24/api3/modules/v1/controllers/ProductController.php @@ -0,0 +1,51 @@ +all(); + $prices = ArrayHelper::map($pricesData, 'product_id', 'price'); + + $parentData = Products1c::find() + ->select(['id', 'name']) + ->where(['tip' => 'products_group']) + ->all(); + $parent = ArrayHelper::map($parentData, 'id', 'name'); + + $noData = Products1C::find() + ->select('id') + ->where(['tip' => 'products_group']) + ->andWhere(['or', ['like', 'name', 'категории А'], ['like', 'name', 'духи']]) + ->all(); + $no = ArrayHelper::getColumn($noData, 'id'); + + $productsData = Products1C::find() + ->where(['tip' => 'products', 'view' => 1]) + ->andWhere(['not in', 'parent_id', $no]) + ->orderBy('name ASC') + ->all(); + + $products = []; + foreach ($productsData as $product) { + if (isset($prices[$product->id])) { + $products[] = [ + $product->id, + trim($product->name), + trim($parent[$product->parent_id] ?? null), + $prices[$product->id] + ]; + } + } + + return $products; + + } +} -- 2.39.5