Script for automatic import of ubercart items

I would like to make a cron job, which to update the curent ubercart nodes from CSV file , wich is uploaded via ftp. What is the best way for that (and to be invisible for the users)
Who is Participating?
UltrusConnect With a Mentor Commented:
I don't have an ubercart installation in front of me, but I'm pretty sure you'll be playing with the following:

Drupal in general (product pages/descriptions)
node (top level overview data containing vid of node_revisions which has the guts - creating node link above will help with that)

term_* (used for product categories and hierarchy I think, maybe other uses)
uc_* (working from memory, but you will need to use many of these, some not)

Other random notes:
-backups, backups, backups
-be sure to clear your Drupal cache after direct db alterations otherwise some changes may not be seen right away. Directly, that's any table starting with cache_, and 'cache' itself.
-It may be handy to configure attributes in ubercart first before importing data, and figuring out a compatible way to reference this data when importing. Maybe not: it just seems complicated pre-coffee.

Using the API, check out the links above for bootstrapped examples, and also check out the API documentation page for ubercart at:

I'd lean towards the API first as it handles a lot of the things that often get missed when dealing with the database directly. I mention this as I built my own API that fed data to an external service from my Drupal site. Starting with direct database queries, I ran into tangles that got complicated, rewriting with Drupal API which reduced my code drastically and was helpful when I changed my Drupal CCK field structure.

Let me know if that helps. :)
Wright your own php code to perform exactly what you want to do, and insert it to cron.php
When running, (based on your configuration), the task will be executed in the background.
Observer_123Author Commented:
I suppose it have to   update to the followinf tables node, image and files?
Is that All? Can I use some API from ubercart module instead of direct database insert?
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

You ask a big question, but I love your interest in automation. Here's a partial set of answers:

Here's some great conversation about updating nodes from a spreadsheet (could be Ubercart related or other nodes I suppose):

If you want to go the API route, you'll need to create a module that plugs in (I'm still learning this stuff) then start looking up a lot of API documentation, or to cheat you would create a script and 'bootstrap' Drupal to it so that you could call Drupal API functions. Either way, you have some research and hard work to do.

Here's more info on how to bootstrap Drupal to a script (and create a new node):

Does that help inspire something?

Observer_123Author Commented:
for me the both (APIs or direct database input) could be decision.
Could you point me in which tables I have to insert/delete to add/remove ubercart items?

Observer_123Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.