Starting a website

Managing a website

DIY website plans from $65 per month.

Making websites work

Contact us or phone 1300 400 934 to get started.

Programmatically importing data into Drupal

Matt's picture

It is possible to programmatically import data into Drupal. Data can be imported from a script that uses Drupal Node API.

You would want to programmatically load data into Drupal where you have a regularly updated list of products, where data is sourced from an external database or where you are doing a migration from another system.

The two methods in Node API that you will want to have a look at are node_load and node_save. Examples include:

Another example would be to create a service function call that calls node_load and node_save. See http://drupal.org/project/Services for information about creating Drupal services.

In a nutshell:

  1. Call node_load to create a node.
  2. Map variables (from your data file) to the node.
  3. Save the node.

Which method you use will depend on volume and frequency of how often you want to load data.

If you have a requirement for images consider using http://drupal.org/project/imagefield_import before importing data. Whilst importing data images can be linked to node.

Taxonomy (categories) can also be managed programmaticly whilst working with the node.

Remember in Drupal content is a node. When loading data the key is to use node_load and node_save.

 

Similar

No related items were found.