S
S
symply_rabbit2019-07-30 03:24:33
1C-Bitrix
symply_rabbit, 2019-07-30 03:24:33

What is wrong with sorting products by price?

To sort products by price I use the code

<?if ($_GET["sort"] == "price")
{
$arParams["ELEMENT_SORT_FIELD"] = "catalog_PRICE_1";
}
if ($_GET["sort"] == "name")
{
$arParams["ELEMENT_SORT_FIELD"] = "NAME";
}
?> 
<li class="up"><a href="?sort=price"><strong><span> по цене </span></strong></a></li>
<li class="up"><a href="?sort=name"><strong><span>алфавиту</span></strong></a></li>

but for some reason it divides the entire list of products and shows 15 products from 10 to 1000 rubles, for example, and the rest from 500 to a thousand. what could be the problem? what is wrong with the code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2019-07-30
@anton99zel

Example:

<?
$sortField = 'shows'; // поле сортировки по умолчанию
$sortOrder = 'DESC'; // направление сортировки по умолчанию
if (
    isset($_GET["sort"]) && isset($_GET["method"]) && (
            $_GET["sort"] == "name" ||
            $_GET["sort"] == "catalog_PRICE_1" ||
            $_GET["sort"] == "shows" ||
            $_GET["sort"] == "created")){
      $sortField = $_GET["sort"];
      $sortOrder = $_GET["method"];
  }
?>

<div class="sort">Сортировка по:
    <a href="?sort=catalog_PRICE_1&method=desc">цене</a> 
    <a href="?sort=shows&method=desc">популярности</a> 
    <a href="?sort=created&method=desc">новинкам</a>
    <a href="?sort=name&method=asc">названию</a>
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question