Generate link in PHP using eZ Platform API
In eZ Platform there are plenty of links to go around as you create locations and tree structures. In templates it is well documented how to generate links to locations, but in PHP this is not well documented.
Here is how to do it:
// Load the URL Alias Generator service from the container
$urlAliasGenerator = $this->get('ezpublish.urlalias_generator');
// Get path
$urlAliasGenerator->getPathPrefixByRootLocationId($hit->valueObject->id);
That's easy, nothing to it. You just need to know how to do it. There might be some issues with siteaccess paths with this method, though.