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

eZ Community » Forums » eZ Publish 5 Platform » Updating Priority via Public API...
expandshrink

Updating Priority via Public API without removing current location

Updating Priority via Public API without removing current location

Monday 24 November 2014 4:39:20 pm - 2 replies

Hello eZ Forum,

at the moment a am trying around with setting the priority of images via public api. Setting priority while creating a new image is easy with 

 $locationCreateStruct->priority = 3;

But it seems there is no easy way while doing the same with existing content without deleting the current location and setting it again?

I have tried to load all locations of the content which has to be updated and then set the priority with:

$locations = $locationService->loadLocations( $contentInfo );                
foreach ($locations as $key => $location) {
$location->priority = 3;
}

Any Idea how to solve this problem in an easier way?

 

Best regards,

Jacob

Edit:

I found at the end of the Kernel LocationService Class some hints for a newLocationUpdateStruct() Function. So i managed this problem with this code:

$locationUpdateStruct = $locationService->newLocationUpdateStruct();
$locationUpdateStruct->priority = $this->priority;
$updatedlocation = $locationService->updateLocation($location, $locationUpdateStruct);

Modified on Monday 24 November 2014 6:11:32 pm by Jacob Ester

Monday 24 November 2014 5:18:48 pm

Hi Jacob. Glad you've resolved it. That's the way to go AFAIK. 

But in case you may encounter it, please note there is know issue with that Here it's 

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

It happens when you try to update a location and you set a priority equal to the one location already has. 

Modified on Monday 24 November 2014 5:19:16 pm by Carlos Revillo

Monday 24 November 2014 6:04:58 pm

Quote from Carlos Revillo :

Hi Jacob. Glad you've resolved it. That's the way to go AFAIK. 

But in case you may encounter it, please note there is know issue with that Here it's 

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

It happens when you try to update a location and you set a priority equal to the one location already has. 

I encountered it in this moment. I wondered why i got lots of:

Could not find 'location' with identifier '3416360'

Patching the kernel is no option here in our company, also we are using 5.2 at the moment.

I will try to skip this error with comparing old and new priority. 

 

Thank you very much for your hint. Saved me some time happy.gif Emoticon

Best regards,

Jacob

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from