From c4cdf7e4f94bc84a9861e7d67cc9ec1440f703a7 Mon Sep 17 00:00:00 2001 From: stes Date: Fri, 10 Nov 2017 11:52:50 +0200 Subject: [PATCH] commit before grand update --- controllers/VariantController.php | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/controllers/VariantController.php b/controllers/VariantController.php index 01c0879..49dac96 100755 --- a/controllers/VariantController.php +++ b/controllers/VariantController.php @@ -13,7 +13,8 @@ use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; - + use yii\web\Response; + /** * VartiantController implements the CRUD actions for ProductVariant model. */ @@ -306,4 +307,42 @@ throw new NotFoundHttpException('The requested page does not exist.'); } } + + public function actionList($q = null, $id = null) + { + \Yii::$app->response->format = Response::FORMAT_JSON; + $out = [ + 'results' => [ + 'id' => '', + 'text' => '', + ], + ]; + if (!is_null($q)) { + $out[ 'results' ] = ProductVariant::find() + ->select( + [ + 'product_variant.id as id', + 'product_variant.sku as text', + ] + ) + ->where( + [ + 'like', + 'product_variant.sku', + $q, + ] + ) + ->andFilterWhere( + [ + '!=', + 'product_variant.id', + $id, + ] + ) + ->limit(20) + ->asArray() + ->all(); + } + return $out; + } } -- libgit2 0.21.4