public function actionSearch($q = null)
{
+ Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
- Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$products = Products1c::find()
- ->select(['id', 'name'])
+ ->select(['id', 'name', 'articule']) // Добавляем 'articule'
->where(['tip' => 'products'])
->andWhere(['ilike', 'name', $q])
->limit(20)
->all();
- return ['items' => $products];
- }
+ $items = [];
+ foreach ($products as $product) {
+ $items[] = [
+ 'id' => $product['id'],
+ 'text' => $product['name'] . (!empty($product['articule']) ? ' (' . $product['articule'] . ')' : ''),
+ ];
+ }
+ return ['items' => $items];
+ }
/**
* Updates an existing Product1CReplacement model.
* If update is successful, the browser will be redirected to the 'view' page.
results: $.map(data.items, function(item) {
return {
id: item.id,
- text: item.name // Убедитесь, что возвращаете корректные данные
+ text: item.text
};
})
};
results: $.map(data.items, function(item) {
return {
id: item.id,
- text: item.name // Убедитесь, что возвращаете корректные данные
+ text: item.text
};
})
};