When you first install Ubercart, you will have a single node type to use when adding new products to your website called Product. The node system in Drupal is a mature system with many contributed modules interacting with it. This is true in Ubercart where you can associate assign default attributes and options to a specific product node type. For this reason, it can be beneficial for your site to have multiple node types available for adding products.
Ubercart lets you add multiple product node types beyond the default Product type. These additional types are referred to as product classes. Ubercart will treat any product class as a normal product node, adding image support to them if enabled and letting customers view them in the catalog and add them to their carts.
A few example use cases may be helpful. Consider product classes if...
- You want to set default attributes/options to different product types to simplify adding products to your site. Ex: an apparel store selling shirts with size and color attributes and pants with size attributes. Consider making a "Shirt" product class and a "Pants" product class with default attributes and options appropriate for shirts and pants.
- You want to use CCK to add various extra fields to some types of products you sell but not all of them. Ex: adding an author field for books. Consider making a special "Book" product class and then adding the fields to this instead of to the generic "Product" node type, especially if you're selling other products that don't have authors!
- You want to make a View that lets customers display a sorted list of products of a certain type. Ex: an apparel store selling hats and t-shirts. Consider making two product classes and adding a filter to your View based on the node type so it can display all your hats or all your t-shirts.
There are certainly many other use cases. For the purposes of this documentation, we'll examine what it takes to implement the first use case. To get started, you need to be logged in as a user with access to administer product classes. Then use the following steps to add and setup your product class.
Creating and configuring a product class:
- Browse to Administer â€º Store administration â€º Products > Manage classes.
- Fill in the information on the form under the heading Add a class. Refer to the help text beneath each field for information, but particularly note that the ID must be unique for Drupal to reference this node type internally while the name will be what gets displayed to the user.
- Submit the form. This will create the new product node type and setup some Ubercart defaults, like images if you're taking advantage of the core image support.
- Click on the edit operations link for the newly added class. You can come here at any time to edit the name or description of the class, but you can edit these settings and more through the normal Drupal node type edit forms at Administer â€º Content management â€º Content types.
- For our use case, if you have the attribute module installed you will see two tabs labeled Attributes and Attribute Options. Use these two tabs to add default attribute and options settings to all products created using this product class. The process is similar to the one used to add attributes and options to individual products detailed here.
- Once you are finished and have saved all the information, you can now start adding products of this class by clicking on the new product class name on the create content page!
That's all there is to it. Because new product classes are created as separate node types, they may also contain their own class specific CCK fields and interact with various other Drupal modules in ways specific to products of that type. An effective use of product classes may significantly simplify your store setup and administration, so it is recommended to plan out your catalog well in advance to prevent any unnecessary changes and lost time later on.
If you must delete a product class sometime down the road, be warned that existing products of that type may be adversely affected.