This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » eZ Publish 5 Platform » Getting MainLocation content...

Getting MainLocation content published immediately before

Getting MainLocation content published immediately before

Wednesday 17 December 2014 5:21:24 pm - 2 replies

I am trying to obtain the main location of a previously published object.
I publish the draft with the legacy kernel like this:

 $content = $this->runLegacyPublish( $draft->contentInfo->id, $draft->versionInfo->versionNo, null ,$job);

Everything seems fine, the content is published and now (some LOC later) i want to create an URL Alias and therefore i need the mainlocation.

$content->contentInfo seems fine:

object(eZ\Publish\API\Repository\Values\Content\ContentInfo)#2575 (13) {
["id":protected]=>  int(2928730)  
["contentTypeId":protected]=>  int(16)  
["name":protected]=>  string(33) "Keine S-Bahnen und Züge am Abend"  
["sectionId":protected]=>  int(1)  
["currentVersionNo":protected]=>  int(2)  
["published":protected]=>  bool(true)  
["ownerId":protected]=>  int(1600802)  
["modificationDate":protected]=>  object(DateTime)#2574 (3) {
    ["date"]=>    string(19) "2014-12-17 16:50:23"    
["timezone_type"]=>    int(3)
    ["timezone"]=>    string(13) "Europe/Berlin"
["publishedDate":protected]=>  object(DateTime)#2569 (3) {
    ["date"]=>    string(19) "2014-12-17 14:19:00"
    ["timezone_type"]=>    int(3)
    ["timezone"]=>    string(13) "Europe/Berlin"
["alwaysAvailable":protected]=>  int(0)
["remoteId":protected]=>  string(36) "219522e0-4e0d-11e4-a2b0-2daab7793fb7"  
["mainLanguageCode":protected]=>  string(6) "ger-DE"  
["mainLocationId":protected]=>  NULL

But as you can already see above, 

$content->attribute('mainLocationId') gives me NULL.

Also, i am not able to load the location via the remotedID i have set (219522e0-4e0d-11e4-a2b0-2daab7793fb7). Trying something like:

$mainLocation = $locationService->loadLocationByRemoteId('219522e0-4e0d-11e4-a2b0-2daab7793fb7')

throws a NotFoundException with 

Could not find 'location' with identifier '219522e0-4e0d-11e4-a2b0-2daab7793fb7'

However, it is apparently possible to get the location(s) via 

 $locationService->loadLocations( $content->contentInfo )


So, where is my fault?


Best Regards,



The WYSIWYG-Editor here has some really annoying bugs. Its not user friendly to post source code, and sometimes it seems to wrap sourcecode with <span> Tags...

Modified on Wednesday 17 December 2014 5:30:42 pm by Jacob Ester

Tuesday 06 January 2015 3:28:38 pm

What do you mean with "published immediately before"?

Are you implying you do it in some event before cache has been cleared for instance? 

Wednesday 21 January 2015 11:56:23 am

Hi André,


no i do in some loc above and then i am just wondering why the published content has "NULL" as mainLocationId with $content->attribute('mainLocationId');

Since my content is already published it should have a main location, shouldnt it?


Best regards,



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

36 542 Users on board!

Forums menu

Proudly Developed with from