catalog->catalog_filter->get_url_data(); $filter = $DATA['catalog']['filter'] ?: array(); $sort = $filter['sort']['values'][0] ?: 0; //$query_order = "a.`Image` DESC, a.`Price` ASC"; $query_select = "( IF( ( a.`stock` = 'krd' AND a.`StockUnits` > 0 ) OR a.`StockUnitsMsk` > 0, 1, 0 ) ) AS `__Avalib`"; //if( $current_sub['Parent_Sub_ID'] == 15 ){ //$query_order = "a.`isHit` DESC, a.`IsSale` DESC, a.`isNew` DESC, a.`Image` DESC"; //$query_order = "a.`isTop` DESC, a.`isHit` DESC, a.`isNew` DESC, a.`Price` ASC, a.`StockUnits` DESC, a.`StockUnitsMsk` DESC"; $query_order = "a.`isTop` DESC, a.`isHit` DESC, a.`isNew` DESC, `__Avalib` DESC, a.`Price` ASC"; //} else { $sort = $sort ?: 1; } if( $sort == 1 ){ $query_order = "a.`Price` ASC"; } if( $sort == 2 ){ $query_order = "a.`Price` DESC"; } $query_where = "a.`Subdivision_ID` IN ( " . ( !empty( $filter[ 'type' ] ) ? implode( ',', $filter[ 'type' ] ) : $where_subs ) . " )"; $query_where .= " AND a.`Subdivision_ID` != 1829 AND a.`Subdivision_ID` != 1834 AND a.`Price` > 0 AND a.`Price` IS NOT NULL AND a.`NotShow` != 1"; $query_where .= " AND ( SELECT s.`Subdivision_ID` FROM `Subdivision` AS s WHERE a.`Subdivision_ID` = s.`Subdivision_ID`"; $query_where .= " AND s.`Hidden_URL` NOT LIKE '/catalog/bio/%' ) = a.`Subdivision_ID`"; $filter_where = $query_where; if( !empty( $filter['have']['values'] ) ){ $where_have = array(); foreach( ( array ) $filter['have']['values'] as $have ){ if( $have == 1 ){ $where_have[] = "( a.`stock` = 'krd' AND a.`StockUnits` > 0 )"; $where_have[] = "a.`StockUnitsMsk` > 0"; } if( $have == 2 ){ $where_have[] = "( ( a.`StockUnits` = '' OR a.`StockUnits` IS NULL OR a.`StockUnits` = 0 ) AND ( a.`StockUnitsMsk` = '' OR a.`StockUnitsMsk` IS NULL OR a.`StockUnitsMsk` = 0 ) )"; } } $query_where .= " AND ( " . implode( " OR ", $where_have ) . " )"; } $query_where .= $DATA['conditions']['where'] ?: ""; } else { $query_where = "a.`Subdivision_ID` != 1829 AND a.`Subdivision_ID` != 1834 AND a.`Price` > 0 AND a.`Price` IS NOT NULL AND a.`NotShow` != 1"; $query_where .= " AND ( SELECT s.`Subdivision_ID` FROM `Subdivision` AS s WHERE a.`Subdivision_ID` = s.`Subdivision_ID`"; $query_where .= " AND s.`Hidden_URL` NOT LIKE '/catalog/bio/%' ) = a.`Subdivision_ID`"; } // Параметр request_type установлен, если страница запрошена скриптом переключения варианта товара $request_type = $nc_core->input->fetch_get_post('request_type'); // Поля, которые отличают варианты друг от друга $variant_fields = array(); if (!function_exists('current_link')) { function current_link($params, $val = null) { if (!is_array($params)) { $params = array($params => ($val == '' ? null : $val)); } if ($get = nc_core('input')->fetch_get()) { $params = array_merge($get, $params); } global $cc_array, $cc, $sub; if (sizeof($cc_array) == 1 || $cc_array[0] == $cc) { return nc_folder_path($sub, null, $params); } else { return nc_infoblock_path($cc, 'index', 'html', null, $params); } } }