I
I
I'm Yoda2018-03-15 20:54:55
1C-Bitrix
I'm Yoda, 2018-03-15 20:54:55

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"];
}

In the component template.
$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;

How to sort by the second size parameter "15 x 20 "? Do a size selection, split it into a substring and replace it with the received GET request, or is there another solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2018-03-16
@megafax

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 question

Ask a Question

731 491 924 answers to any question