eZ Community » Forums » eZ Publish 5 Platform » Search locations by...
expandshrink

Search locations by Criterion\Location\Depth does not work

Search locations by Criterion\Location\Depth does not work

Thursday 13 August 2015 2:43:54 pm - 2 replies

I have Community Project 2014.7 I am trying to make this code works:

 

$criteria = array(
      new Criterion\Subtree( '/2/' ),
      new Criterion\Location\Depth( Criterion\Operator::BETWEEN,  array(0, 100) ),
    );
    $query = new LocationQuery(
    array(
      'criterion' => new Criterion\LogicalAnd( $criteria ),
      'sortClauses' => array( new SortClause\Location\Priority( Query::SORT_ASC ) )
      )
    );
    $query->limit = 3;
    $query->offset = 0;
    $result = $searchService->findLocations( $query );

It just does not return any results. Any suggestions?

Modified on Friday 14 August 2015 11:00:35 am by aleksandar ilic

Friday 14 August 2015 3:56:38 pm

 I guess it works if you skip Depth criterion? Given you set it to 0-100 it's not really needed.

But besides that, did you try with other operators? Like EQ, IN, LT, GT, ... ?
Could be an actual bug with BETWEEN.
But before you report it, please check if it has been fixed in between summer last year and now happy.gif Emoticon

Instructions can be found here: https://github.com/ezsystems/ezplatform/blob/master/INSTALL.md

For step 2 it will basically be:

php -d memory_limit=-1 composer.phar create-project --no-dev ezsystems/ezplatform <directory> dev-master

Monday 17 August 2015 10:43:36 am

It's now working at all with Criterion\Subtree. If I use Criterion\ParentLocationId (I am testing with ParentLocationId = 2 ) it is working only for Depth: 0, 1, 2 (with all operators).

This is not working:
    $criteria = array(
      new Criterion\ParentLocationId( 2 ),
      new Criterion\Location\Depth( Criterion\Operator::GTE,  3 ),
    );

Maybe I do not understand what Criterion\Location\Depth is for. I want implementation of fetch( 'content', 'tree',hash()).

I have next content structure:

Home -> Language1 -> Country1 -> City1 -> School1 -> Course
Home -> Language1 -> Country1 -> City1 -> School2 -> Course
Home -> Language1 -> Country1 -> City2 -> School1 -> Course
....
Home -> Language2 -> Country -> City -> School -> Course
Home -> Language3 -> Country -> City -> School -> Course
...

I want to search for courses by specifying only Language location.

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from