Challenging Drupal Question – Inventory System

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
brianV's picture

A client has asked me to build them a sort of 'inventory system', and I would like to build it using Drupal rather than writing a custom solution for it. However, there are a few things I would like to get some dojo feedback on.

These are all tasks I could do if writing the site from scratch. However, I want to do it in 'the Drupal Way' and take advantage of as much of the existing Drupal infrastructure as possible, so I would appreciate any advice on ways to best do this in Drupal.

Structure

The first challenge is in the structure.

We have 'stores', which I would create as a new content type. Each store would have an unspecified number of product records associated with it, consisting of a product ID and a quantity.

What would be the most effective way to store this information? I assume I should write a module which creates a new table which holds store_id, product_id, and quantity. I am basing this on the fact that I will need to populate this table via CSV parsing (see below)

Viewing the nodes and their related product records would be easy enough – create a menu callback to something like 'view/store/$arg' where arg is the store ID, and manually fetch the information from my new table etc.

Does this sound reasonable? Or is there a better way to approach this?

CSV Parsing and Generating

The second challenge is that they want to be able to update each store's inventory by uploading a CSV file containing the records for that store. How difficult would it be to upload the file, parse it, and update the database records accordingly?

Can anyone point me to any resources that may help me accomplish this?

Also, the clients will be wanting reports. They ideally want Excel exports, but will settle for CSV exports. Is there a 'Drupal Way' to generate these on the fly from the new database table and allow clients do download them?

Thank you in advance for any suggestions!

Comments

CCK and Views as an option

nadavoid's picture

I think you could get almost to your destination just using CCK and Views. The views bonus pack provides a method to get a CSV export.

Using CCK, you could do the following:

  • make a "Store" content type
  • make a "Product" content type
  • add a nodereference field using CCK to the Product content type. Point it to the Stores content type.

If a Store is essentially just a name and not much more, you could use Taxonomy for stores, instead of a content type. Create a Stores taxonomy and each store could be just a term. Then as you create products, you can assign each product to a taxonomy term.

About importing from CSV, I just did a search on the drupal site for "csv import" and found the Node Import module. It may do exactly what you need, right out of the box. If not, it would serve as a good starting point or example.

Good luck! Let us know how the project goes.

Nodes are bad for performance and synchronization

Wim Leers's picture

If you want to use Drupal's "nodes" for storing the content, you should be aware of the fact that it's a pain to automatically sync them, if you want to do it right. Or at least non-trivial. I'm not 100% sure about this though, it's been a while since I looked at this.

Secondly, if this inventory is very big, performance may become an issue, or may require a lot of tweaking.

Personally, I'd probably opt for a completely custom module, that doesn't use Drupal's node system. That makes CSV import and synchronization much easier. Unfortunately, you lose the ability to use Views, since Views only works on nodes. But Views 2 will give you the possibility to use it on different tables than the node table. So if you can wait, wait for Drupal 6 and Views 2. Unless you don't mind writing your own queries - which may give you better performance (Views' performance isn't too bad thanks to caching).

ubercart

kyle_mathews's picture

Have you tried ubercart?

It has a product import and at least the start of reports + inventory management you could build off.
Kyle Mathews

Kyle Mathews

Thanks for the replies,

brianV's picture

Thanks for the replies, folks

@Wim Leers: What do you mean by it being a pain to automatically sync the nodes? Also, how large can the inventory be before you would envision these performance issues. Finally, how long until D6/Views 2 is released? I am fairly sure that D6 isn't too far off, but what is the status of the views project?

@nadavoid: That sounds like a a fairly simple way of doing things. My only concern is, as Wim Leers pointed out, whether the overhead incurred by several hundred nodes needing to be called up to display for a single store would cause the application to grind to a halt.

Brian Vuyk
Senior Developer, PINGV Creative
bv@pingv.com | (315) 849-9733 | Skype: brianvuyk

feeds module

aavgoustinos's picture

in order to import content from CSV file use the https://www.drupal.org/project/feeds
it is very powerful and easy to use.