  |
109 | 109 | | 'weight' => $Qsubproducts->value('products_weight'), |
| |
110 | 110 | | 'weight_class_id' => $Qsubproducts->valueInt('products_weight_class')); |
| |
111 | 111 | | |
  |
112 | | - | $Qvariants = $osC_Database->query('select pvg.id as group_id, pvg.title as group_title, pvg.module, pvv.id as value_id, pvv.title as value_title, pvv.sort_order as value_sort_order from :table_products_variants pv, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.variants_values_id = pvv.id and pvv.languages_id = :languages_id and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id order by pvg.sort_order, pvg.title'); |
| |
| 112 | + | $Qvariants = $osC_Database->query('select pv.default_combo, pvg.id as group_id, pvg.title as group_title, pvg.module, pvv.id as value_id, pvv.title as value_title, pvv.sort_order as value_sort_order from :table_products_variants pv, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.products_variants_values_id = pvv.id and pvv.languages_id = :languages_id and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id order by pvg.sort_order, pvg.title'); |
|
113 | 113 | | $Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS); |
| |
114 | 114 | | $Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS); |
| |
115 | 115 | | $Qvariants->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES); |
| |
|
|
 |
… |
|
123 | 123 | | 'group_title' => $Qvariants->value('group_title'), |
| |
124 | 124 | | 'value_title' => $Qvariants->value('value_title'), |
| |
125 | 125 | | 'sort_order' => $Qvariants->value('value_sort_order'), |
  |
| 126 | + | 'default' => (bool)$Qvariants->valueInt('default_combo'), |
|
126 | 127 | | 'module' => $Qvariants->value('module')); |
| |
127 | 128 | | } |
| |
128 | 129 | | } |
| |
|
|
 |
… |
|
307 | 308 | | |
| |
308 | 309 | | if ( $value_exists === false ) { |
| |
309 | 310 | | $values_array[$group_id]['data'][] = array('id' => $value_id, |
  |
310 | | - | 'text' => $value['value_title']); |
| |
| 311 | + | 'text' => $value['value_title'], |
| |
| 312 | + | 'default' => $value['default']); |
| |
| 313 | + | } elseif ( $value['default'] === true ) { |
| |
| 314 | + | foreach ( $values_array[$group_id]['data'] as &$existing_data ) { |
| |
| 315 | + | if ( $existing_data['id'] == $value_id ) { |
| |
| 316 | + | $existing_data['default'] = true; |
| |
| 317 | + | |
| |
| 318 | + | break; |
| |
| 319 | + | } |
| |
| 320 | + | } |
|
311 | 321 | | } |
| |
312 | 322 | | } |
| |
313 | 323 | | } |
| |
|
|
 |
… |
|
364 | 374 | | if ( $Qcheck->numberOfRows() < 1 ) { |
| |
365 | 375 | | return true; |
| |
366 | 376 | | } else { |
  |
367 | | - | $Qvariants = $osC_Database->query('select p.products_id from :table_products p, :table_products_variants pv where p.parent_id = :parent_id and p.products_id = pv.products_id and pv.variants_values_id in (":variants_values_id") group by pv.products_id'); |
| |
| 377 | + | $Qvariants = $osC_Database->query('select p.products_id from :table_products p, :table_products_variants pv where p.parent_id = :parent_id and p.products_id = pv.products_id and pv.products_variants_values_id in (":products_variants_values_id") group by pv.products_id'); |
|
368 | 378 | | $Qvariants->bindTable(':table_products', TABLE_PRODUCTS); |
| |
369 | 379 | | $Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS); |
| |
370 | 380 | | $Qvariants->bindInt(':parent_id', $Qproduct->valueInt('products_id')); |
  |
371 | | - | $Qvariants->bindRaw(':variants_values_id', implode('", "', $variants)); |
| |
| 381 | + | $Qvariants->bindRaw(':products_variants_values_id', implode('", "', $variants)); |
  |
372 | 382 | | $Qvariants->execute(); |
| |
373 | 383 | | |
| |
374 | 384 | | while ( $Qvariants->next() ) { |