Answer the question
In order to leave comments, you need to log in
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>
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question