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 ...

  • And where exactly did you shove "CATALOG_PRICE_1"? - Yevhen Bondarenko
  • here it is more correct to ask the question: what are your products? with trade offers or without? - maxkrasnov

1 answer 1

This component is not to search for a product, but to search for any content. There is no concept of price and out of the box, only two types of sorting according to the documentation . Other sorting should be implemented independently. There is an article in which there is an example of refinement sorting. In it, the task is somewhat different, but as a blank you can use. In this case, the following points should be taken into account: 1. Do not forget to limit the search area to only products, or consider where to find such content, for example, found content (not goods) 2. The code from the article above, you need to refine the price request. (Please note that in the article below, the IDs that are found are passed to a bitrix: catalog.section component, but it is not enough to configure sorting by price, because the IDs are transferred page by page). 3. Be sure to cache the result later.

By the way, if you really do not need the morphology and flexibility of the search and just search in the name for the exact phrase finding - then you can do without the search component. And without your request at the beginning. Transfer your filter directly to the bitrix: catalog.section component.