Commit 0d3c7b1df3bf39352097362250b3e04ca6f3da95

Authored by Administrator
1 parent 67a0e32e

20.07.16

Showing 1 changed file with 16 additions and 19 deletions   Show diff stats
common/modules/product/models/Category.php
... ... @@ -231,14 +231,7 @@ class Category extends \yii\db\ActiveRecord
231 231 $query1 = (new Query())
232 232 ->distinct()
233 233 ->select([
234   - 'option_id',
235   - 'tax_option.*',
236   - 'tax_group.*',
237   - 'tax_option.alias as option_alias',
238   - 'tax_group.alias as group_alias',
239   - 'tax_value_string.value as value',
240   - 'tax_option.sort AS tax_option_sort',
241   - 'tax_group.sort AS tax_group_sort',
  234 + 'option_id'
242 235 ])
243 236 ->from('tax_option')
244 237 ->innerJoin('product_variant_option', 'tax_option.tax_option_id = product_variant_option.option_id')
... ... @@ -253,14 +246,7 @@ class Category extends \yii\db\ActiveRecord
253 246 $query2 = (new Query())
254 247 ->distinct()
255 248 ->select([
256   - 'option_id',
257   - 'tax_option.*',
258   - 'tax_group.*',
259   - 'tax_option.alias as option_alias',
260   - 'tax_group.alias as group_alias',
261   - 'tax_value_string.value as value',
262   - 'tax_option.sort AS tax_option_sort',
263   - 'tax_group.sort AS tax_group_sort',
  249 + 'option_id'
264 250 ])
265 251 ->from('tax_option')
266 252 ->innerJoin('product_option', 'tax_option.tax_option_id = product_option.option_id')
... ... @@ -272,9 +258,20 @@ class Category extends \yii\db\ActiveRecord
272 258 ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE])
273 259 ->andWhere(['!=', 'product_variant.stock', 0]);
274 260 $query3 = (new Query())
275   - ->select('*')
276   - ->from(['subquery' => $query1->union($query2)])
277   - ->orderBy('tax_group_sort, tax_option_sort');
  261 + ->select([
  262 + 'tax_option.*',
  263 + 'tax_group.*',
  264 + 'tax_option.alias as option_alias',
  265 + 'tax_group.alias as group_alias',
  266 + 'tax_value_string.value as value',
  267 + 'tax_option.sort AS tax_option_sort',
  268 + 'tax_group.sort AS tax_group_sort',
  269 + ])
  270 + ->from(['tax_option' ])
  271 + ->where(['tax_option.tax_option_id'=>$query1->union($query2)])
  272 + ->innerJoin('tax_group','tax_group.tax_group_id = tax_option.tax_group_id')
  273 + ->innerJoin('tax_value_string', 'tax_value_string.tax_option_id = tax_option.tax_option_id')
  274 + ->orderBy('tax_option.sort, tax_group.sort');
278 275 return $query3;
279 276 }
280 277  
... ...