Programmatically importing data into Drupal
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:
- Node_Import - Module that imports data (for example http://drupal.org/project/node_import provides a module that imports data).
- Programmatically from a PHP script refer to technique used in http://acquia.com/blog/migrating-drupal-way-part-i-creating-node for example of how to create script.
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:
- Call node_load to create a node.
- Map variables (from your data file) to the node.
- 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.





