I have a standard bitrix component: component.search, its settings have not changed at all, standard ones, they are not customized in any way, the problem is that I just can’t force it to sort the found product by price so that immediately after the search it will automatically output the product sorting by price, from most to less ... google-stumbled upon a piece of code right here, but alas ... zero emotion from sorting
https://dev.1c-bitrix.ru/support/forum/forum6/topic43895/
but I cannot use it at all ... I substituted the variable according to my data, namely, instead of 'catalog_PRICE_' I substituted 'CATALOG_PRICE_1', because it is in it that I keep the prices ... component, I repeat, the standard, and sorting with the same standard means is not wants, even from the skin out ...
CModule::IncludeModule('iblock'); $El = new CIBlockElement; $dbRes = $El->GetList( array( 'SORT' => 'ASC', ), array( 'NAME' => '%' . $_GET['q'] . '%', 'IBLOCK_ID' => 1, 'ACTIVE' => 'Y', '>CATALOG_PRICE_1' => 1, 'SECTION_GLOBAL_ACTIVE' => 'Y', 'SECTION_SCOPE' => 'IBLOCK', array( 'LOGIC' => 'OR', array('!PREVIEW_PICTURE' => false), array('!DETAIL_PICTURE' => false), ), ), false, false, array('ID') );
if (count($arIds) < 10 && changeLang($_GET['q']) != $_GET['q']) { $dbRes = $El->GetList( array( 'SORT' => 'ASC', ), array( 'NAME' => '%' . changeLang($_GET['q']) . '%', 'IBLOCK_ID' => 1, 'ACTIVE' => 'Y', 'SECTION_GLOBAL_ACTIVE' => 'Y', 'SECTION_SCOPE' => 'IBLOCK', '>CATALOG_PRICE_1' => 0, array( 'LOGIC' => 'OR', array('!PREVIEW_PICTURE' => false), array('!DETAIL_PICTURE' => false), ), ), false, false, array('ID') ); while ($arRes = $dbRes->Fetch()) { $arIds[] = $arRes['ID']; } }
$arElements = $APPLICATION->IncludeComponent( "bitrix:search.page", "empty", Array( "RESTART" => $arParams["RESTART"], "NO_WORD_LOGIC" => $arParams["NO_WORD_LOGIC"], "USE_LANGUAGE_GUESS" => $arParams["USE_LANGUAGE_GUESS"], "CHECK_DATES" => $arParams["CHECK_DATES"], "arrFILTER" => array("iblock_" . $arParams["IBLOCK_TYPE"]), "arrFILTER_iblock_" . $arParams["IBLOCK_TYPE"] => array($arParams["IBLOCK_ID"]), "USE_TITLE_RANK" => "N", "DEFAULT_SORT" => "sort", "FILTER_NAME" => "NoFilter", "SHOW_WHERE" => "N", "arrWHERE" => array(), "SHOW_WHEN" => "N", "PAGE_RESULT_COUNT" => "( 20 - count($arIds) )", "DISPLAY_TOP_PAGER" => "N", "DISPLAY_BOTTOM_PAGER" => "N", "PAGER_TITLE" => "", "PAGER_SHOW_ALWAYS" => "N", "PAGER_TEMPLATE" => "N", "CACHE_TYPE" => "A", "CACHE_TIME" => 3600 * 100, ), $component, array('HIDE_ICONS' => 'Y') ); Here, in fact, the component itself ... what to do, I will not apply ...