Answer the question
In order to leave comments, you need to log in
How to sort products by property (do not pass by)?
Hi all! On the site I sort goods by properties price, popularity, power and size . Trouble arose with the last parameter. The size property has entries like "15 x 20", 30 x 20", "25 x 10", etc. Sorting works, but I want to make sorting by size work on the second parameter, not the first
. before calling the component I output
if ($_GET["sort"] == "property_PRICE" ||
$_GET["sort"] == "property_STATUS" ||
$_GET["sort"] == "property_POWER" ||
$_GET["sort"] == "property_SIZE") {
$arParams["ELEMENT_SORT_FIELD"] = $_GET["sort"];
$arParams["ELEMENT_SORT_ORDER"] = $_GET["method"];
}
$arSortIndex = 0;
foreach ($arSortField as $sort_field):
$method = $_GET["method"] == "desc" ? "asc" : "desc";
$sort = $_GET["sort"] == "desc" ? "asc" : "desc";
?>
<li class="list-group-item">
<a href="<?= $APPLICATION->GetCurPageParam("sort=" . $sort_field . "&method=" . $method, array("sort", "method")); ?>" class="<?= $_GET["sort"] == $sort_field ? "active " : "not-active " ?><?= $_GET["method"] ?>" rel="nofollow">
<?= $arSortText[$arSortIndex] ?>
</a>
</li>
<?
$arSortIndex++;
endforeach;
Answer the question
In order to leave comments, you need to log in
Divide this parameter into 2 different ones. They will be surrogates. Do the separation through the event of saving the element of the infoblock, then 1s will be picked up and manual saving. And sort by surrogate. Unless for the first time for the goods you will have to set everything with a script.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question