Answer the question
In order to leave comments, you need to log in
How to implement a unique sorting index for a product in a section?
Good day!
The client needs to manage the sorting of each product in all sections of the site. Management must be at the partition level. That is, if the sort value for a particular section is filled, then we use it, otherwise we use the standard sort index.
So far, only the creation of a custom field comes to mind, which will display all the products belonging to the section and additional. input field for the index opposite the product name.
Questions:
Answer the question
In order to leave comments, you need to log in
1) You can receive and process your custom section field in result_modifier.php
2) Starting from version 18.6.900, the inheritors of the \Bitrix\Iblock\Component\ElementList class
support sorting by element ID sequence.
You can modify the logic in result_modifier.php and pass $arElements // an array of IDs in the required order for the id field - by ID in the "ELEMENT_SORT_ORDER" key
https://dev.1c-bitrix.ru/user_help/components/cont...
Let's add to the standard sorting fields, in our case "number of views, i.e. popularity - shows", our own sortings created on the properties of the element - PRIORITET - if we want to raise the element higher in the list and NOSKLAD - if we want to remove goods that are missing in stock below. We will not display, but we will take into account:
$arSort = array("PROPERTY_NOSKLAD"=>"ASC", "PROPERTY_PRIORITET"=>"DESC", "shows"=>"DESC");
if (
isset($_GET["sort"]) && isset($_GET["method"]) && (
$_GET["sort"] == "name" ||
$_GET["sort"] == "catalog_PRICE_1" ||
$_GET["sort"] == "shows" ||
$_GET["sort"] == "created")){
$arSort = array($_GET["sort"]=>$_GET["method"]);
}
$res = CIBlockElement::GetList($arSort, Array($arrFilter, $arFilter), false, Array("bShowAll"=>false, "nPageSize"=>18, "iNumPage"=>$pn), $arSelect);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question