eZ Community » Forums » Developer » Adding a new object relation in PHP
expandshrink

Adding a new object relation in PHP

Adding a new object relation in PHP

Tuesday 12 June 2012 3:58:03 pm - 2 replies

I'm trying to update an object relations-attribute with more relations. Here's the function being used:

public function updateObject($contentObjectID)    {
$result = false;
$contentObject = eZContentObject::fetch( $contentObjectID );
if( $contentObject instanceof eZContentObject ) {
$params = array();
$params['attributes'] = $this->data;
$params['remote_id'] = date( 'Y/m/d H:i:s', time() );
$params['section_id'] = 1;
$result = eZContentFunctions::updateAndPublishObject( $contentObject, $params );
 }
  return $result;
 }

But this only replaces the current object relations each time. How can I add more object relations without loosing the existing ones?

Modified on Tuesday 12 June 2012 4:16:41 pm by Fredrik Tidemann

Wednesday 13 June 2012 9:30:02 am

You're looking for addContentObjectRelation  - something like this:

$contentObject->addContentObjectRelation( $relatedObjectID, $editVersion,  $contentClassAttributeID, $relationType );

 

 

Friday 15 June 2012 9:51:28 am

Works perfectly, thanks!

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from