--- /dev/null
+<?php
+
+namespace yii_app\api3\modules\v1\controllers\search;
+
+use yii\helpers\ArrayHelper;
+use yii_app\api3\controllers\NoActiveController;
+use yii_app\records\Products1c;
+
+class ItemController extends NoActiveController
+{
+ public function actionItemsSite($limit, $name) {
+ $products = Products1c::find()->select(['id', 'name'])->where(['tip' => 'products_group'])->all();
+
+ $parent = ArrayHelper::map($products, 'id', 'name');
+
+ $products2 = Products1c::find()->select('id')->where(['tip' => 'products_group'])->andWhere(['LIKE', 'name', '%категории А%', false])->all();
+
+ $no = ArrayHelper::getColumn($products2, 'id');
+
+ $products3 = Products1c::find()->select(['id', 'parent_id', 'name'])->where(['tip' => 'products'])->andWhere(['view' => '1'])
+ ->andWhere(['NOT IN', 'parent_id', $no])->andWhere(['LIKE', 'name', '%' . $name . '%', false])->orderBy(['name' => SORT_ASC])
+ ->limit($limit)->asArray()->all();
+
+ foreach($products3 as $row) {
+ $p[]=[$row["id"],"".$row["name"]." (".$parent[$row["parent_id"]].")"];
+ }
+
+ return $p;
+ }
+}
\ No newline at end of file