eZ Community » Forums » eZ Publish 5 Platform » Sorting by Priority
expandshrink

Sorting by Priority

Sorting by Priority

Wednesday 04 September 2013 3:56:36 pm - 12 replies

Hello,

I wrote a Controller for fetching nodes below a parent node. As example I used the DemoController for the TopMenu. Somehow sorting by priority seems to be buggy. I don't get the sorting I see in the backend.

Is this a known issue?

This is how I use the sort clause.

Regards

Kostas

 'sortClauses' => array(
                                new SortClause\LocationPriority( Query::SORT_ASC )
                        )

Wednesday 04 September 2013 5:14:28 pm

Hello,

If you change Query:SORT_ASC to Query:SORT_DESC, have you a difference ?

Can you test to erase your code and add this line at the bottom of your Query like that :

 
$query = new Query(
      array(
                [YOUR_CODE_WITHOUT_SORTCLAUSES]
      )
);
 
$query->sortClauses = array(new SortClause\LocationPriority( Query::SORT_ASC ) );

 

Do you seen this documentation : http://share.ez.no/blogs/thiago-campos-viana/ez-publish-5-tip-search-cheat-sheet ?

Regards,

Modified on Wednesday 04 September 2013 5:15:19 pm by AGUENOT Nicolas

Wednesday 04 September 2013 6:07:11 pm

Hi,

it seems that the problem appears if you create a new location for a node. In the new location the priority seems not to be read correctly. In the location where I first created the object everything's fine.

Maybe someone could try to reproduce this?

Version: 2013.6

 

Thanks

Kostas

Modified on Wednesday 04 September 2013 6:40:00 pm by Konstantinos Strigkos

Thursday 05 September 2013 2:57:31 pm

Hi,

I've the same issue with 2013.7 version.

I don't know if EzPublish team knows this bug.

Have you check jira.ez.no bug tracker to see if a similar problem is recorded ?

Regards

Thursday 05 September 2013 4:32:29 pm

Hi there,
we are currently experiencing almost the same issue on our sites.
I can confirm that issue and was able reproduce this. I also debugged that for a while and found one possible cause for this strange behavior.

But one step after another:
1  this problem occurs when you are referencing the same content object in two different locations.
2. the system uses only the priority values from one location but it can be the wrong location for you
3. thats all happens because of a array_flip and maybe in first place because of a wrong sql query

For example you have a mainMenuLocation where you have three childs attached to (contentObjectIds: 80,81,3117) and you have a quickLinksLocation with two childs (contentObjectIds: 80,81).
So both locations are pointing to contentObjects 80 and 81.

The query to fetch the locationChildren manages it somehow to get something like that which is the first problem:

$contentIds = (0 => 80, 1 => 81, 2 => 3117, 3 => 80, 4 => 81)
with this ids the content gets fetched which is probably wrong. There should be only 80, 81 and 3117. Because we only asked  for the childs of the first location.

Later in the code... array_flip() is called on $contentIds which results in this
$contentIds = (80 => 3, 81 => 4, 3117 => 2,)
And here you actually see that in our example he will use the results he would get for the second location.

Then the system have the priority values from the second location even when you asked for the child's of the first location like in our small example.

You can set in both locations the same priority numbers (if possible) to get a proper sorting or just use different objects in the two locations.

Hopefully I was able to help some one out here with my explanation
Regards,
Sebastian

Modified on Thursday 05 September 2013 4:39:17 pm by Sebastian Kopatz

Thursday 05 September 2013 7:15:20 pm

Hi,

this sounds like a bug. I could not find any issues on this so issue should be reported, if you also want to speed up this being resolved you can do a Pull Request with a integration test which points out the failure.

The next step is to add a new test, this is added in the eZ/Publish/API/Repository/Tests folder, either add this tests to one of the existing test cases once in that folder, or add a test case in Regression folder which will be picked up automatically.

For examples take a look at the Regression link and it's history for how to add regression tests, or for how to add a proper test coverage in the main test cases see this recent pull request for what is needed (but for this issue it needs to be done in SearchServiceTest.php)

Good luck happy.gif Emoticon

Modified on Thursday 05 September 2013 7:16:17 pm by André R

Friday 06 September 2013 8:48:56 am

Hello,

thanks for the feedback and confirming that this might be a possible bug.

I will open a ticket for this issue and when I find the time for it I will also have a look at creating a proper test for this and starting a pull request.

Update:

https://jira.ez.no/browse/EZP-21518

Regards,
Sebastian

Modified on Friday 06 September 2013 10:15:54 am by Sebastian Kopatz

Friday 06 September 2013 10:39:00 am

Hi Guys,

thanks for the great community work.

Hopefully the bug is fixed very soon because location handling is one of the big powers of eZ.

Sebastian, please make an update here as soon as you create the test.

Thanks!

Regards
Kostas

Friday 13 December 2013 12:16:03 pm

Hi,

I'm currently facing this bug. My current solution is to manage to keep my content in one unique location at a time.

>Sebastian how have you managed to deal with it since september ? Do you have any "hacky fix" that i could use too ?

Thanks !

Tuesday 20 May 2014 4:53:08 pm

Hi all,

I also run into this bug, using community version 2014.1... I found the bug reported as https://jira.ez.no/browse/EZP-21518 but it looks that it is still unassigned. As Konstantinos put it, location hadnling is one of the very big strengths of eZ Publish. I hope this bug can be fixed soon.

Thanks,
Donat

Modified on Tuesday 20 May 2014 4:54:52 pm by Donat Fritschy

Thursday 22 May 2014 3:05:42 pm

As Peter Spanja commented in https://jira.ez.no/browse/EZP-21518, the Location Search implementation available in 5.3/2014.03 fixes this problem.

Be aware however that the SearchService still has this very problem. As we usually need to filter location children by content types, the use of loadLocationChildren is somewhat limited.

Thursday 31 July 2014 1:06:23 am

Hello
I use a 4.5 version of EZ Publish, and I try to sort the menu by priority:
     $menu_list=fetch( 'content', 'list', hash( 'parent_node_id', $root.node_id,
                                                'class_filter_type', 'include',
                                                'class_filter_array', array('folder'),
                                                'sort_by', array( 'priority', true() )
                                                ) )
so this doesn't work.
My question is: are there any other way to solve a sorting like this?

Modified on Thursday 31 July 2014 1:07:01 am by Pavel Miron

Thursday 31 July 2014 9:27:53 am

Quote from Pavel Miron :

Hello
I use a 4.5 version of EZ Publish, and I try to sort the menu by priority:
     $menu_list=fetch( 'content', 'list', hash( 'parent_node_id', $root.node_id,
                                                'class_filter_type', 'include',
                                                'class_filter_array', array('folder'),
                                                'sort_by', array( 'priority', true() )
                                                ) )
so this doesn't work.
My question is: are there any other way to solve a sorting like this?

Hi Pavel

this forum is for eZ 5 specific discussion, so you will find little help here blunk.gif Emoticon

Your fetch seems correct to me and it certainly is the way to do it in 4.x. For a full reference and many examples see https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/list

Regards,
Donat

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from