Forums / Developer / Content Import Questions

Content Import Questions

Author Message

Alex Jones

Tuesday 20 January 2004 11:53:04 am

After spending a lot of time combing through the forums, documentation and contributions I have managed to thoroughly confuse myself as to the best way to importat data. So, I hope some of you can help me determine the best path to follow as I work on a new site.

[The Challenge]
I need to import data from a text file (I'm not sure if it will be comma or tab delimited as of yet) into eZ publish 3.3. This data will be updated at least once every 24 hours. This is a brand new site, so I do not have to worry about legacy data when importing for the first time.

[My Questions]
1. Does anyone have a good foundation script written to import text into eZ publish? I will have quite a few fields to import per entry (item name, item number, item comments, item price, various specifications). The vast majority of imported fields will be simple text lines, though I will need one text field. I should not need XML Text field import, though I am quite happy to use it, if that is what is available. I do not need to worry about binary data.

2. What pitfalls do I need to be prepared to avoid?

3. The information at http://ez.no/developer/ez_publish_3/documentation/development/importing_attribute_data looks promising, but I am unable to download the the testimport.php script that is linked on that page. Does anyone have that script available so I could look at it?

As always I appreciate your help!

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

K259

Tuesday 20 January 2004 2:49:36 pm

I think this is the same:

http://pubsvn.ez.no/viewcvs/*checkout*/ezp/releases/3.3-beta1/scrap/testimport.php?rev=4289

Copy the total url..the * stops identifying that the whole thing actually is an url ;)

Best regards

Bruce Morrison

Tuesday 20 January 2004 3:03:13 pm

Hi Alex

I've worked on a number of sites that have been done using eZ publish and utilise external data. I've come to the conclusion that unless the data is going to be managed via eZ publish (i.e. you are doing an initial import and the data will be edited) it is much more efficient to store the data in a its own table(s) and to write a module to display it.

Cheers
Bruce
http://www.designit.com.au

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

andreas spahr

Tuesday 20 January 2004 11:33:20 pm

Hi,

I imported a boundle of data using something like I described in the forum:
http://ez.no/developer/ez_publish_3/forum/developer/importing_hundrets_of_articles

Hope it helps,
andreas

Willie Seabrook

Wednesday 21 January 2004 3:21:12 am

Hi Alex,

I've had the nightmare job of consolodating and importing data from multiple mysql database tables along with various filemaker databases into ez. Previously all the data was syncd manually, (which means that there was data inconsistancy which is whole other problem altogether)

I havn't done anything with regards to text files though. Although my code gets all the data into a consistant associative array format:

$array[*ezcontentclassidentifer*][*value*]

where ezcontentclassidentifier is the string id (not the numerical id) of the content object attribute.

So working from there it takes care of pretty much everything.

Your first stage would be to get the text file data into an associatve array format (which will be a piece of cake). Then you should create ez objects from there.

Once I have my code finished (it still has many hickups) I'll release it.

The interesting problem I have had to face is keeping ez publish and filemaker synchronized. An update in filemaker must appear on the website an update on the website must appear in filemaker. Its messy I know but filemaker is entrenched in their system and moving from it would have been impossible. I keep them syncd by:

ez -> filemaker: workflow publish events
filemaker -> ez: cronjob run every x minutes.
Comparing versions, timestamps and values.

Could you tell us more on the nature of your problem. Is the text file simply feeding ez, or will ez also feed the text file?

IE is data *appended* to the text file (so that you'll have objects that need to be *updated* and also you'll have to create *new* objects each time the script is run) or is the data file being overwritten each time so that the only task of the script will be to *create* new ez objects and publish them?

willie dot seabrook at levity dot co dot nz

Alex Jones

Wednesday 21 January 2004 7:07:02 am

Thanks for the feedback everyone! This is exactly the type of help I was looking for. :)

Zinistry, thank you for the URL, I will check it out!

Bruce, thank you for your thoughts regarding a separate table. This data will not be modified through eZ publish, so that may well be a good direction to go.

Andreas, the thread you point to has been quite helpful to me as I approach this challenge. That post is a great example of why I love the eZ publish community.

Willie, the data exchange will remain one-way (external data source -> eZ publish); making my life much easier. But, the external source will need the ability to add new items and modify existing ones.

Again, thank you all for the feedback so far! Please keep it coming. I will post my thoughts and experiences as I move forward as well.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Roy Viggo Pedersen

Monday 26 January 2004 3:12:37 am

Hi!

I have done something similar to what you're after. Data are created and updated in an internal product database and exported to a text file, which is then imported into eZ. Products are never created in eZ.

The import script has to check whether the product exist or not, and create or update it. I used the examples in contributions as a base (Import 2.2 to 3.x), and I used the remote_id field in ezcontentobject as an identifier. I made the remote_id out of class name and ID from the product database, just as it was done in the 2.2 -> 3.x example.

The greatest challenge was to find the correct parent node to create the product under. The category tree was created manually in eZ, and I made a map table with categories from the product database and node numbers from eZ. Not an elegant solution, but it was the only way for me. You may use eZContentObjectTreeNode::childrenByName instead if you have a simple category tree, e.g:

$nodeFolder =& eZContentObjectTreeNode::fetch( $productFolderId );
$existsNode =& $nodeFolder->childrenByName( $category );
if ( count( $existsNode ) > 0 ) {
$parentNodeID = $existsNode[0]->attribute( 'main_node_id' );
}

But then you also have to create the category node it it don't exists.

This import system has been in use for 4 months now, and working great. Take a look at http://www.damm.no/content/view/full/10896 for an example of the result (in Norwegian).

Roy

Alex Jones

Monday 26 January 2004 6:46:24 am

Roy, thank you for the additional information. I have managed to get the foundation for an import script working thanks to a lot of help from Paul F. I have standard text fields and prices importing properly and about to work on XML Text Fields. After that I need to add the ability to update items that already exist. Would you mind posting the code you are using, or is it obvious in the import script? Your help would be greatly appreciated!

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Eirik Alfstad Johansen

Monday 26 January 2004 6:57:52 am

Hi Alex,

For XML data import you might want to check out the text2xml class at http://www.ez.no/ez_publish/documentation/development/importing_attribute_data if you haven't already. It worked like a charm for me.

Sincerely,

Eirik Johansen

Sincerely,

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

Alex Jones

Monday 26 January 2004 8:06:43 am

Thank you Eirik. I believe it will prove quite helpful. :)

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

steve walker

Tuesday 01 June 2004 6:31:14 am

Alex,

Have you had any joy on this? I have started to look into the issue too, see post at:

http://ez.no/community/forum/setup_design/import_product_data_from_xl_spreadsheet_customisation_of_administration_interface

Seems quite a tricky conundrum...

Steve.

http://www.oneworldmarket.co.uk

Alex Jones

Tuesday 01 June 2004 6:59:48 am

Steve, I do have a working script to import data, thanks to the help on this forum. See this thread for more information: http://www.ez.no/community/forum/developer/importing_update_entry_if_it_already_exists

I'm afraid I don't have time to provide details as I am preparing for a business trip, but if you haven't found a solution by the time I am back (mid-next week), I will see what I can do to help.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

steve walker

Tuesday 01 June 2004 7:13:37 am

Alex,

Thanks for the reply.

Currently I'm trying to just assess the feasability so I can create a quote for a potential client. The answer seems to be 'Yes', but its clearly going to be a bit of a learning curve for me to implement.

Have a good trip!

Steve.

http://www.oneworldmarket.co.uk

Alex Jones

Wednesday 09 June 2004 7:44:55 am

Steve, I hope you have found enough information to move forward in your estimate. :) If not, I will try to answer what I can.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

steve walker

Wednesday 09 June 2004 7:54:13 am

Alex,

Cheers for the note. I have built in a good amount of time to develope this and am waiting to hear back from the client. Fingers crossed as it would be an interesting project to build out.

Steve.

http://www.oneworldmarket.co.uk

eZ debug

Timing: Jan 18 2025 11:22:25
Script start
Timing: Jan 18 2025 11:22:25
Module start 'content'
Timing: Jan 18 2025 11:22:26
Module end 'content'
Timing: Jan 18 2025 11:22:27
Script end

Main resources:

Total runtime1.7526 sec
Peak memory usage4,096.0000 KB
Database Queries242

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 587.7109180.8359
Module start 'content' 0.00751.5510 768.5469909.5313
Module end 'content' 1.55850.1940 1,678.0781362.5625
Script end 1.7525  2,040.6406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.2313210.0002
Check MTime0.00150.0875210.0001
Mysql Total
Database connection0.00090.050010.0009
Mysqli_queries1.620092.43272420.0067
Looping result0.00330.18602400.0000
Template Total1.707697.420.8538
Template load0.00200.115220.0010
Template processing1.705597.313720.8528
Template load and register function0.00010.007110.0001
states
state_id_array0.00180.102910.0018
state_identifier_array0.00310.175020.0015
Override
Cache load0.00210.12081080.0000
Sytem overhead
Fetch class attribute can translate value0.00340.192390.0004
Fetch class attribute name0.00100.0599180.0001
XML
Image XML parsing0.00250.142790.0003
class_abstraction
Instantiating content class attribute0.00000.0025230.0000
General
dbfile0.00680.3884390.0002
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
15content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
22content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 54
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs