Answer the question
In order to leave comments, you need to log in
How to sort the data in the shopping cart alphabetically?
I don't understand where the sale.basket.basket component gets its data from. It seems that I am changing the array and I see that the data has changed, but in appearance they have not changed, and here I have big questions, how to sort
in the js-templates/basket-item.php file.
So I sorted in result_modifer.php
$product = array();
foreach ($arResult["BASKET_ITEM_RENDER_DATA"] as $key => $value){
$product[$key] = $value["NAME"];
}
array_multisort($product, SORT_ASC, $arResult["BASKET_ITEM_RENDER_DATA"]);
Answer the question
In order to leave comments, you need to log in
In the basket-item.php file, goods most often come in the $arResult['GRID']['ROWS'] array,
so your result_modifer.php should contain something like this
class Kudis
{
public static function sortByNameAsc($arrA, $arrB)
{
$a = $arrA['NAME'];
$b = $arrB['NAME'];
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
}
uasort($arResult['GRID']['ROWS'], ['Kudis', 'sortByNameAsc']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question