Products & Product Types in Drupal Commerce Module Guide

In this first in a series of Drupal Commerce Guides, we work through setting up the relevant Drupal CMS modules and taking the first steps in our e-commerce site creation tutorial. To get started, we need to understand what Commerce's Product and Product Types are, as well as how to implement them.

Understanding Products and Product Types

Products vs Product Types in Drupal Commerce Module

Let’s say you own a boutique with an online e-commerce store where you might sell gift baskets, wine, and perhaps tickets to special events. These are your Product Types and to put it simply, they are just the types of Products that you sell. Within these Product Types, you sell may sell a variation of individual Products. For instance, within a wine Product Type, you may sell a Pinot Noir wine and a Pinot Blanc wine. Pinot Noir and Pinot Blanc are individual Products of the Product Type wine. A Product Type is not unlike a Content Type in many ways. In fact, it was Drupal 7's entity system that inspired the team behind the project, Commerce Guys, to structure and build Drupal Commerce using entities. In Drupal Commerce, a Product Type is a specific bundle based on a custom product entity much like my example with wine. Each bundle can have fields attached to it with product attributes and variations to further define Products, much like you would define fields in Content Types.

Products can be easily compared to Nodes as well. They're product content added to their respective Product Types.

Module Installation

In this tutorial, I'm assuming that you already know how to download and install modules, so I've foregone those steps. Here's a one-liner for Drush to grab the stable/suggested version and dependencies:

drush en commerce -y

Required Modules

Dependencies

For reference, I've enabled all Commerce related modules for this Drupal Commerce tutorial.

I’ve installed a few unrelated modules that you may see in my tutorial video above. Those include:

Create a Custom Product Type

Let's begin adding a Product Types in Drupal Commerce. When you enabled the Product UI module earlier, a basic Product Type was created. A basic Product Type includes:

  • a product SKU
  • the title of the product
  • a price field
  • a status field

Let's create a custom Product Type.

Navigate from Administration Store  Products Product Types. Select Add Product Type.

Drupal Commerce Tutorial: Creating Product Types

Configure the Product Type, then select: "Save and add fields."

Drupal Commerce Tutorial: Configure Product Types

The base Product Type fields are created by default when you add a new Product Type, see below. Add fields to customize your Product Types.

Drupal Commerce Tutorial: Creating Product Types

For my wine Product Type, I've added an image field and a List (text) field to define my wine type. These two fields are known as informational field variations. In other words, these fields will not alter the price of my Product. Instead, these fields will provide additional information about my Product.

I'll also add a List (text) field for a vintage selection. My vintage selection will alter how the Product looks and the price of my Product, however. Therefore, I will select "Enable this field to function as an attribute on the Add to Cart forms."

Drupal Commerce Tutorial: Creating Product Types with Attributes

Next, adjust the Display settings on your Product Type. Choose Manage Display and adjust accordingly. Typically, I hide the Product SKU, Status, and most Field Labels. Save and begin adding your Products.

Drupal Commerce Tutorial: Creating Product Types and Managing the Display

Add Products to your new Product Type

Navigate to Administration Store Products Add a Product. Enter the Product information and save.

Drupal Commerce, Add Product

Drupal Commerce, Create Product

Once you've added your Products, it's time to learn about creating Product Displays to make your Products available to your customers.

Reach out If you're interested in having us build an e-commerce solution in Drupal for you or your organization. Think this tutorial is useful? Don't forget to share!

 
 

This is part of a tutorial series on Drupal Commerce. See more below:
Tutorial: Creating Product Types and Products in Drupal Commerce
Product Display: Contextual Field Output in Guide
Customizable Products with Drupal Commerce Module Guide​

tracy's picture