if ($guid) {
- $existingReplacements = Product1cReplacement::find()
- ->select('guid_replacement')
- ->where(['guid' => $guid])
- ->column();
- if ($existingReplacements) {
- $query->andWhere(['not in', 'id', $existingReplacements]);
+ if ($guid == "guid"){
+ $existingGuids = Product1cReplacement::find()
+ ->select(['guid'])
+ ->distinct()
+ ->column();
+ if ($existingGuids) {
+ $query->andWhere(['not in', 'id', $existingGuids]);
+ }
+ }else{
+ $existingReplacements = Product1cReplacement::find()
+ ->select('guid_replacement')
+ ->where(['guid' => $guid])
+ ->column();
+
+ if ($existingReplacements) {
+ $query->andWhere(['not in', 'id', $existingReplacements]);
+ }
}
+
}
$products = $query->asArray()->all();
'ajax' => [
'url' => \yii\helpers\Url::to(['/crud/product1c-replacement/search']),
'dataType' => 'json',
- 'data' => new JsExpression('function(params) { return {q:params.term}; }'),
+ 'data' => new JsExpression('function(params) { return {q:params.term, guid: "guid"}; }'),
'processResults' => new JsExpression('function(data) {
return {
results: $.map(data.items, function(item) {