Script for automatic import of ubercart items

Posted on 2011-05-13
Medium Priority
Last Modified: 2012-05-11
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)
Question by:Observer_123
  • 3
  • 2
LVL 16

Expert Comment

ID: 35753761
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.

Author Comment

ID: 35754268
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?
LVL 10

Expert Comment

ID: 36040884
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?

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 36254383
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?

LVL 10

Accepted Solution

Ultrus earned 2000 total points
ID: 36254931
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: http://www.ubercart.org/docs/api

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. :)

Author Closing Comment

ID: 36255049

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month16 days, 20 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question