Answer the question
In order to leave comments, you need to log in
How to re-sort $arResult['ITEMS'] in Bitrix?
Good afternoon!
The question is a puzzle, for sure for me) so after a week of searching for a solution I decided to write here.
There is Bitrix, a catalog of goods. The catalog is unloaded from the supplier every day and we cannot change the structure.
There are products that are similar in themselves and they need to be combined into a mini section, or only one product should be shown, this is another matter. It is ideal to shove them into the TP, but unloading also does not allow to do so. I see only an option to remake the array.
Those. there is a page with a list of elements, parameters set to show 8 elements:
1. T-shirt blue art.=1
2. T-shirt green art.=1
3. T-shirt red art.=1
4. T-shirt black art.=3
5. T-shirt blue art . .=2
6. T-shirt green art.=2
7. black T-shirt art.=2
8. black T-shirt art.=3
I see eight elements, everything is ok.
I reordered the $arResult['ITEMS'] array and got the grouping:
[1]
1. T-shirt blue art.=1
2. T-shirt green art.=1
3. T-shirt red art.=1
[2]
1. T-shirt blue art. =2
2. T-shirt green art.=2
3. T-shirt black art.=2
[3]
1. T-shirt black art.=3
2. T-shirt black art.=3
It seems to be displayed, it seems ok, but instead of the 8 elements specified in the settings , 3 are shown (that's right, there are actually 8 elements, but they regrouped and only mini sections are visible).
It would seem that you can set to show not 8 but 20 elements on the page, in order to conditionally get the same 8 sections, but when paging, the grouping is done in different ways, a different number of elements is graded and you don’t understand how many to display
Where do I need to re-sort the array to get the already given number?
I tried to push the resort into the result_modifer of the catalog_section component, but this did not work
Answer the question
In order to leave comments, you need to log in
The selection takes place in component.php or class.php Pagination
pages are also formed there.
Those. all further modifications of the $arResult array will lead to pagination problems.
You have 2 ways
1) Write your own component and do all the grouping in component.php before fetching
2) Make the grouping earlier.
On the events of adding an element to the infoblock, or write an agent that will process the elements and group them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question