Import CSV in EZP 3.9 : Missing doc

Author Message

Kristof Coomans

Friday 09 February 2007 6:29:25 am

Hi Sébastien,

Include kernel/classes/ezcontentclass.php

a little bit off topic but maybe this one can be useful for you too: http://pubsvn.ez.no/community/trunk/extension/cddb. I'll upload the content classes I use this weekend.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Sébastien Antoniotti

Friday 09 February 2007 7:10:41 am

Hi Kristof ,

Thanks for your help, I have looked your module, but you don't include the library who contains the eZContentClass declaration. I think this is because you are into a module, but I'm not into a module (I execute my script by the shell).

I have included this files :

include_once( 'kernel/classes/ezcontentclass.php' );
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
include_once( 'kernel/classes/eznodeassignment.php' );

And running this :

$newAlbumId=ajouterAlbum($album1_name,$album1_year,true,64);
print_r($newAlbumId);

I get this error :

Array
(
    [result] => Array
        (
            [statut] => erreur
        )

    [msg] => node_id=64 doesn't seem to be a valid node id
)

But 64 is a valid node id, so I think that this instruction : $node =& eZContentObjectTreeNode::fetch($node_id);
is not executed properly, but I don't know why =(

eZ Publish Freelance
web : http://www.webaxis.fr

Kristof Coomans

Friday 09 February 2007 7:25:30 am

Hi Sébastien

It's better to write a real eZ command line script by using the eZScript class, so your eZ environment gets initialized properly. Take a look at the scripts in bin/php as an example. There are also some related code snippets on eZpedia: http://ezpedia.org/wiki/en/content/search?SearchText=script

Some other useful forum topics:
http://ez.no/community/forum/developer/php_script_problem
http://ez.no/community/forum/developer/launching_a_script

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Sébastien Antoniotti

Friday 09 February 2007 7:42:33 am

This links are very good !!

I think I can succes with this, thanks ;)

eZ Publish Freelance
web : http://www.webaxis.fr

Kristof Coomans

Friday 09 February 2007 7:48:36 am

Stub node on eZpedia: http://ezpedia.org/wiki/en/ez/command_line_scripts

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Sébastien Antoniotti

Friday 09 February 2007 8:00:43 am

dev evening in perspective !

eZ Publish Freelance
web : http://www.webaxis.fr

Daniele Nocentini

Wednesday 28 February 2007 12:54:43 am

Hello!
I try the ezcvsimport function with a simple class with only eztextline datatype, now I would like to try with date or date/time datatype, what is the right syntax in cvs file for this datatype?

Antica Bottega Digitale srl
http://www.abd.it

H-Works Agency

Thursday 08 March 2007 7:21:45 am

What is the correct syntax to import 'ezoption' datatype ?

Thanx

EZP is Great

Stefan de Bruijn

Sunday 15 July 2007 11:17:38 am

When trying to import data into a custom class, which contains an ezuser type, i get the following error:

# php bin/php/ezcsvimport.php -d -v --creator=14 --class=ow_persoon 203 teztuser.csv
Going to import objects of class ow_persoon under  node 203 from file teztuser.csv

Fatal error: Call to a member function on a non-object in /.../kernel/classes/datatypes/ezuser/ezusertype.php on line 393

With the modification from Rodrigo Pinheiro i got the same result, maybe because this only works for the standard 'user' class. With a mod of his mod, i can now import ezusers:

At line ' switch ( $datatypeString = $attribute->attribute( 'data_type_string' ) ) { '
Add the following case:


		case 'ezuser':
		// create array of userdata
		$csvUserData = explode( '|', $dataString );
	   	$userAccountObject = eZUser::fetch($attribute->ContentObjectID);
		
		// only first 2 items are used
		$username = $csvUserData[0];
               	$email = $csvUserData[1];
               	
               	// password is created by ez publish, not from csv
               	$password = eZUser::createPassword(6, 0);
               	$confirmPassword = $password;
               	$password_hash = md5( "$username\n$password" );
               	$userAccountObject->setInformation($contentObject->attribute('id' ), $username, $email, $password, $confirmPassword);
               	$userAccountObject->store();
               	// echo user and created password 
               	echo "user: " . $username . " password: " . $password;
               	break;

Kristof Coomans

Wednesday 18 July 2007 5:49:36 am

The error you get is probably related to this bug report: http://issues.ez.no/11092

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Daniele Nocentini

Monday 30 June 2008 9:01:08 am

When I try to import string that contain a special char such as "è à ì ò" frequent in italian's words, the import script truncate the string before the special char.

Antica Bottega Digitale srl
http://www.abd.it

H-Works Agency

Tuesday 01 July 2008 3:10:52 am

Hello,

I think this is a charset problem between your string and ezp.

You should try to make both compatible. Maybe using a utf8_encode(), or another charset conversion php function, before passing your string to the toString() import function.

EZP is Great

Daniele Nocentini

Tuesday 01 July 2008 3:31:08 am

I have modified the line 163 from:

$attribute->fromString( $dataString );

to:

$attribute->fromString( utf8_encode($dataString) );

now work fine and import also string with special chars.

Thanks.

Antica Bottega Digitale srl
http://www.abd.it

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:33:47
Script start
Timing: Jan 18 2025 19:33:47
Module start 'layout'
Timing: Jan 18 2025 19:33:47
Module start 'content'
Timing: Jan 18 2025 19:33:48
Module end 'content'
Timing: Jan 18 2025 19:33:48
Script end

Main resources:

Total runtime0.9701 sec
Peak memory usage4,096.0000 KB
Database Queries92

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 588.4453152.6250
Module start 'layout' 0.00690.0039 741.070339.9219
Module start 'content' 0.01080.9578 780.9922772.6641
Module end 'content' 0.96860.0014 1,553.656330.2891
Script end 0.9701  1,583.9453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.3608160.0002
Check MTime0.00150.1560160.0001
Mysql Total
Database connection0.00110.112110.0011
Mysqli_queries0.871589.8385920.0095
Looping result0.00100.1005900.0000
Template Total0.927995.720.4640
Template load0.00200.203120.0010
Template processing0.925995.446720.4630
Template load and register function0.00010.007610.0001
states
state_id_array0.00090.094610.0009
state_identifier_array0.00130.138320.0007
Override
Cache load0.00190.1941700.0000
Sytem overhead
Fetch class attribute can translate value0.00060.064750.0001
Fetch class attribute name0.00060.0631170.0000
XML
Image XML parsing0.00170.177950.0003
class_abstraction
Instantiating content class attribute0.00010.0056250.0000
General
dbfile0.00110.1159350.0000
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
12content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
13content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
19content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 55
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs