Forums / Developer / Node assignment and node_ID

Node assignment and node_ID

Author Message

Olav Bringedal

Thursday 24 February 2005 1:12:42 am

I have written a script thats imporing products. Since there's around 500 of them id like them categorised into folders. This is a part of the script that does that, and it works. However the last part with ($node =& eZContentObjectTreeNode::fetch($node_id)) seems to me as pretty unnecceary, as I'd say it was natural that EznodeAssignment somehow contained that node_id after storing. Is it just me overlooking something obvious?

		$folderclass =& eZContentClass::fetch( 1 );
		
		$contentObject =& $folderclass->instantiate( $userID, 1 );
		$contentObject->setAttribute( 'name', $folder['navn'] );
		$contentObject->store();
			
		//assign new object to parent node
		$nodeAssignment =& eZNodeAssignment::create( array(
			'contentobject_id' => $contentObject->attribute( 'id' ),
			'contentobject_version' => $contentObject->attribute( 'current_version' ),
			'parent_node' => $merch_node,
			'is_main' => 0)	);
				
		$nodeAssignment->store();
				
		//snipped version code
	}
		
	$node =& eZContentObjectTreeNode::fetch($node_id);
	$children =& $node->subTree( array( 'Limitation' => array() ) );
	foreach ($children as $child)
	{
		//Set each products group to $child->MainNodeID;
		
	}


Senior Consultant
http://Umoe-consulting.no

Eirik Alfstad Johansen

Thursday 24 February 2005 9:12:45 am

Hi Olav,

Have you tried $nodeAssignment->attribute("id") ?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Olav Bringedal

Friday 25 February 2005 12:45:03 am

Thanks, I wish it was that easy :)

debug shows that's the unique id of the node assigmnent

class eznodeassignment {
  var $PersistentDataDirty = false;
  var $ID = 6875;
  var $RemoteID = 0;
  var $ParentRemoteID = '';
  var $ContentobjectID = 6868;
  var $ContentObjectVersion = 1;
  var $ParentNode = 69;
 ...
}

the folder itself gets the values: 

class ezcontentobjecttreenode {
 ...
  var $Name = 'Billetter';
  var $ClassIdentifier = 'folder';
  var $ClassName = 'Folder';
  <b> var $NodeID = '4359';</b>
  var $ParentNodeID = '69';
  var $MainNodeID = '4359'; 
  var $ContentObjectID = '6868';
...
}


Senior Consultant
http://Umoe-consulting.no