Drupal Commerce Usability: Bulk Product Creation / Import Tools

rszrama's picture

Overview: Drupal Commerce is a fresh implementation of the Ubercart feature set on Drupal 7 using fieldable entities to the max and depending on Views and Rules. What a product is has been separated from how a product is displayed (see this thread for more details), and the attributes system has been completely redone to work through fields on product types and enforce unique SKUs for every variation of a product. While greatly improving the underlying data model, this adds to the complexity of listing products for sale, especially when closely related products need to be sold through the same display (i.e. multiple sizes of a particular t-shirt style). This project will take advantage of the field settings for fields on product types and Token patterns to create bulk product generation forms and enhancements to the Product Reference field and its Add to Cart form display formatters to present these products for sale.

Description: The Product module defines a fieldable product entity that can have multiple bundles and creates a default product type upon installation. The Product UI module defines a default UI for managing product types, forms for adding and managing products, and Views integration for viewing products.

The Product Reference module defines a field that references any number of products from other entities for display to the end user. Products themselves aren't currently meant to be viewed but rather referenced by the nodes (or other points of display) that market the products. The Cart module defines a display formatter for the product reference field that takes the referenced product IDs and builds a simple Add to Cart form using the data. When multiple products of the same type are referenced, the Add to Cart form will include widgets to select the appropriate product for purchase based on the fields of that product type.

For example, an apparel store might sell every style of t-shirt in small, medium, and large. With the core components, the process from product creation to merchandising for each style of t-shirt is:

  1. Create a new "T-shirt" product type and add a required Size field to it with the available sizes as options.
  2. Add a new T-shirt product for each Size with a unique SKU, likely using a pattern based on the Size (SHIRT-001-S, SHIRT-002-M, etc.).
  3. Create a "Product" node type and add a required Product Reference field to it that is multiple entry, uses the product autocomplete widget, and uses an Add to Cart Form display formatter.
  4. Add a new Product node for the style of t-shirt with images and descriptive text marketing the t-shirt for sale. Reference each variation of the style of t-shirt through the Product Reference field.

It's easy to see how this process will be cumbersome for store owners, especially as product types include more options per attribute or even multiple attributes. While the core modules will remain austere in terms of the default UI, this GSoC project should result in a module that aids in the speedy creation of large sets of products.

For example, steps 2 and 4 above could happen through a single form where a user chooses a product type, a Token based SKU pattern (perhaps using a default pattern per product type), and a display node type. Upon providing a product title, "T-shirt Style 001", and submitting the form, the module would automatically create a product for every variation of the attributes with a unique SKU based on the attribute values. Additionally, a new display node would be created that automatically references the newly created products, and the user would be redirected to the node's edit form to supply images for the new style and additional descriptive text.

The pay-off here is huge. The Commerce systems are necessarily complex, but a module like this can add a much needed usability layer to enable store owners to quickly list a large amount of products for sale. Assuming the module users the Forms API properly (i.e. defining a bulk product creation API that is called from form submit handlers instead of building all the functionality into the submit handlers), it will have huge implications for product import which has historically been a pain in Ubercart.

Additional functionality can target the much requested ability to list multiple products for sale via a single Add to Cart form using a custom display formatter for the product reference field that uses multiple quantity boxes to add any number of each referenced product to the shopping cart at once. Students should feel free to brainstorm usability solutions based on past experience, feedback in the Ubercart forums / issues, or your own bright ideas for making the lives of store owners easier.

The end result of this project will be a Bulk Product Creation module and patches to improve the core Commerce modules as necessary. The student who takes this on will be hailed as a hero and learn a thing or two about Drupal 7, fieldable entities, Drupal Commerce, and the Forms API along the way. ; )


Contact Details (email at minimum): Provided as necessary.

Difficulty: Medium


Just wanted to add that I'm

rszrama's picture

Just wanted to add that I'm sorry for coming so late to the game. I'll try to get some eyes on this and will be happy to flesh my thoughts out further as necessary. I think there's easily a full Summer's worth of work here, and this could easily be broadened out or morphed into other usability improvements for the right student. As a mentor, I'm happy to communicate via g.d.o, the issue tracker on d.o, and IRC in #drupalcommerce or whatever channel is necessary.

Ryan, First off, great work

wildkatana's picture


First off, great work with Ubercart, I have used it on many of my sites before. It is somewhat complex and has a steep learning curve, but the power and flexibility it has are awesome! I like this project proposal because it deals with the User Experience, which I think is very important for everyone who uses the module.

I have missed the past two GSOC's due to traveling, and I am going to apply for this one while I'm still in school. I have an avid interest in all things E-Commerce, and I would like to take up this project. I have a lot of experience with Ubercart, having written numerous modules that take advantage of the Ubercart API. I am happy to see that it is moving on to Drupal 7 as Drupal Commerce, and I would like to help it become successful.

Looking at your current process you described, I can see how this would quickly become cumbersome. I can make the Bulk Product Creation module, which will provide the features you described, as well as a good API to use for Product Import. This would definitely speed things up for Store Owners, having everything in one field and then generating the products based on the Attributes and Options.

I also like the Add to Cart widget ideas, but I'm not sure what the best way to do it would be. Do you have any examples from other Shopping Carts that I can look at?

I have a few questions that we can brainstorm and figure out the best way to do things:

What would happen when users want to change the products available, like if they want to discontinue the XS size of a shirt? Should there be a way to automatically clean-up discontinued products, or should this be handled by simply marking those products as out of stock? I can see how deleting the products could cause problems with users who have already purchased them in the past, because then their Order History wouldn't show the products anymore.

What if they want to add a new attribute or option, like XL for a shirt, after the bulk creation has been done? Should the new products be automatically generated and added to the Product Display?

Can you think of anything else that would need to be covered by this project?

I am very familiar with the Forms API, having build numerous modules for Drupal 6, but Drupal 7 and Fieldable Entities are new to me, so I'm excited to jump in and get my hands dirty.

Looking forward to your ideas!

Leighton Whiting

Leighton, thanks for stepping

rszrama's picture

Leighton, thanks for stepping up and sorry it's been 10 days without a response. I'm encouraged by your post, and I think you're asking some good questions. For example, I hadn't thought of what to do with Product Reference field data for discontinued products. They do have a status field that can be toggled, but I'm not sure if disabling a product should clean-up the field data or simply be reflected in the add to cart form. It'd be good to work these issues out over the summer, so I'm going to comment on your GSoC proposal in the queue and have offered to mentor. Here's hoping it works out. : )

importation ?

aem34's picture


about importation :
as an example, currently moving from an oscommerce 2.x site (900 products approx.), i've translated product datas into csv to import them, and their images (1 to 4 images per product).

i suppose it could be the same with a brand new ubercart site with 200 products more or less, and the images appart in some folders but rightly named after each product name or SKU.

the thing i'm currently on is :
how to import those images into ubercart's nodes, imagecache'ing them, as the image count per node is 1 upto 4 ?

all other things (SKU, name, price, weight, ...) is ok per csv but for imagecache images, this is really a pain in the ass :)

Not sure how far the migrate

kthull's picture

Not sure how far the migrate module has come but I've had problems with this same issue. I hodgepodged some php together based on several examples found on d.o to import the node data and then if memory serves, I wrote the data into the files table by an sql import. In your import table, you have to map the new nid to the old data so you can populate the tables with the proper data. The delta column serves as your image 1 to 4. After import and clearing the cache, everything was pretty well set. Imagecache took care of itself. Oh, and I ftp'd the images to the /sites/default/files folder. Later in the process, I found that the filefield paths module will let you tokenize the files folder with the nid, and it can be retroactively applied, so I cleaned up my files folder afterward.

I imported about 600 nodes and maybe 5000 images this way. I'm sure there's a better way, but this worked for me.

I organize camps!
DrupalCamp Fox Valley: http://drupalcampfv.org
MidCamp: http://midcamp.org

Bulk Import

FreeGroup's picture


you can use www.dbtube.org for bulk import of CSV or Excel into the
database. It's a very flexible PHP application which can installed on your web server.



Updating the thread...

eltermann's picture


I'd like to apply for GSoC2011, and I got interested in getting involved with Drupal Commerce project.
Is there any "community proposal" for this year?

I work with Drupal and have some experience with Ubercart module.
Nevertheless, I don't know the actual needs of Commerce project.