A
A
Anton2019-08-20 16:42:26
1C-Bitrix
Anton, 2019-08-20 16:42:26

How to sort elements?

Bitrix has sorting shows - the average number of impressions (number of impressions / duration of the show), i.e. in fact, popular products are displayed above.
How to limit this popularity in time, so that the first products are popular not for all time, but for the last 30 days? And then we display the products in any other order....
Well, in principle - how to limit sorting??
For example, show only 10 new products first, then any other sorting, and at the end other new items...
i.e. Restrictions on number or on the period are necessary.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex-1917, 2019-08-20
@alex-1917

Here, according to your link, Tanyukha writes:
this is exactly where the array is formed, just for sorting, where did the word filtering come from ???

$sortField = 'ID'; // поле сортировки по умолчанию
$sortOrder = 'ASC'; // направление сортировки по умолчанию
if (
    isset($_GET["sort"]) && isset($_GET["method"]) && (
$_GET["sort"] == "name" || 
             $_GET["sort"] == "catalog_PRICE_3" ||
            $_GET["sort"] == "property_PRODUCT_TYPE" ||
            $_GET["sort"] == "timestamp_x")){
      $sortField = $_GET["sort"];
      $sortOrder = $_GET["method"];
  }

and already in the component you apply the generated parameters from the array
"ELEMENT_SORT_FIELD" => $sortField,
        "ELEMENT_SORT_ORDER" => $sortOrder,

S
serginhold, 2019-08-20
@serginhold

no way, if it's scary to write sql queries or create new tables
https://bxapi.ru/src/?module_id=iblock&name=CIBloc...

function GetShowedFunction()
{
    return " IfNULL(BE.SHOW_COUNTER/((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(BE.SHOW_COUNTER_START)+0.1)/60/60),0) ";
}

bitrix does not store data in b_iblock_element when it showed something, it stupidly stores the date of the first show and uses it
for this:
1) score on this Wishlist
2) use your own sql query with join on the table b_catalog_viewed_product (CatalogViewedProductTable), if it is is about goods in the store
3) point 2. does not fit, because. the data is not a product, so we make our own table with views, where the dates of the views will be

Y
Yaroslav Alexandrov, 2019-08-21
@alexyarik

You take a blank of a custom complex component in the materials of exam No. 2 and write your logic for generating an array of a list of goods in it.
Most likely you will have to write your functionality of the average number of impressions for the last 30 days in your module and store the impression values ​​in your database tables.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question