Forums / Developer / Need help for update object via script

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Need help for update object via script

Author Message

Pierre Tissot

Tuesday 04 December 2007 6:31:14 am

Hi,

I'm working in scripts, those script can create the same object in several languages, but right now I have to update de same objects.
The problem is that once created the update reset all data and the objects gets empty, here's the code:

   $version =& $contentObject->version( $contentObject->attribute( 'current_version' ) );
   $version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );                        
   $version->store();                            
   
   $contentObjectAttributes =& $version->attribute( 'data_map' );

   // this $fields array as the attributes names of the class with the value to update it.

   foreach($fields as $key=>$value){
      $contentObjectAttributes["$key"]->setAttribute( 'data_text', $fields[$value] );
      $contentObjectAttributes["$key"]->store();
   }
   
    $contentObject->store();
    
    include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
    eZOperationHandler::execute( 'content', 'publish', 
                                       array( 'object_id' =>    $contentObject->attribute( 'id' ),
                                       'version'   => $contentObject->attribute( 'current_version' ) ) );                    

I really don't no what might be wrong here. I don't know if any problem arise from the fact that each object as 4 versions each one in the right language.

Thanks for the help.

PiR

Oliver Frommel

Tuesday 04 December 2007 7:41:32 am

I don't know if that helps in your particular case but you might to try using eZContentLanguage::setCronjobMode();
It somehow makes your script language agnostic as far as I know :) It is a bit underdocumented as well.

Best
Oliver