Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Adding product variations

From: Create Your First Online Store with Drupal Commerce

Video: Adding product variations

We now have three products on our site. Let's review how they got there. We first created the products themselves based on a product type called product, and if we go up to Store, and click Products, we see the three products themselves. These are all based on the product type called product. After we created these products, we displayed them by creating product display nodes, and we can see those by going to Content, and there are all of our product display nodes. Creating and displaying product in Drupal Commerce always happens in those two steps.

Adding product variations

We now have three products on our site. Let's review how they got there. We first created the products themselves based on a product type called product, and if we go up to Store, and click Products, we see the three products themselves. These are all based on the product type called product. After we created these products, we displayed them by creating product display nodes, and we can see those by going to Content, and there are all of our product display nodes. Creating and displaying product in Drupal Commerce always happens in those two steps.

First you create the product, then you create a node to display it. It's important to understand this thoroughly, because now we're going to add a complication. You will notice that two of these products are very similar; they're both half liter bottles of olive oil. One of them is lemon- flavored, and the other is plain. They are, in effect, variations on each other. Let's say that we have several flavors, and several bottle sizes. I am going to show you an easier way to create a series of product variations that also improves the shopping experience.

We will do this in three steps. First, we are going to add a field to the product itself that describes the variation, and we will call that Flavoring. Second, we will apply that flavoring to the relevant products, so the plain olive oil will be labeled as plain, and so on. Third, and this is the tricky part, we are going to create a single product display node that displays all of those variations, so we won't need to have three separate display nodes. Instead, the customer will go to them, and select the flavor that he or she wants.

We will start by going back to our product type. To do that, we go up to Store, Products, and Product Types. Now I am going to add a field to our product. It's going to be called Flavoring, and that's going to be of the list type, List (text), and it will be a select list; that's fine. Our options will be Plain, Lemon, Basil, and Chili. Let's scroll down, and save, and then we have some additional options as well.

For example, I will make the Default Flavoring Plain, since that's mostly what we are going to be selling. This Attribute Field Setting is a little bit complex, but you'll see what it does when we start shopping. We do want it to be enabled, however. Go down further, it shows us, again, our Allowed values, and save. Now you will see what happens when we add a new product. How about a half liter bottle of Chili olive oil? I have a graphic and some text that describes that olive oil in my exercise files. If you received this product on a disk, or are a premium member of lynda.com, you also have these exercise files.

We will do that by going up to Add product, and then go to the text file that has all of that information. The SKU is going to be 1003, there is our title, our image, a little alternate text to help with the accessibility, and for price, let's make that $10. And then here's our new field; Flavoring. That's going to be Chili, and save product.

Before we go on, I want to edit the other two olive oil bottles: Lemon-flavored olive oil, and the plain olive oil. This is step two that we had. So I will go in and edit. Here is the Lemon-flavored one; I'll change it to Lemon, and save. And go back to our products, and edit the plain one, so that it says Plain. Very good! Now as usual, we will add a product display to show that Chili-flavored olive oil we added. This part works the same as before.

We go up to Add product display, and start entering the information. I have this all in the exercise file. So I open it; so I will copy my title, and the body text. Scroll down and choose our product -- remember it was Chili-Flavored olive oil -- it pops up, and say that it's Edible oils. Scroll down and save. There; now when we go back to our front page, it shows up the same as all of the other products that we have in our store.

But that's not where we're going to stop. We now want to have all three of the different flavored edible oils to show up in one product display node. To do that, we create one product display node, which will reference multiple products. Before going on, I'm going to make the selection a little bit easier by going up to Structure, and Content types, and product display. Now this field here where it references the product; if we edit it, we see that it's this autocomplete text field. That's actually a little bit harder to work with, because we don't see what all the products are.

I am going to change it to a select list, make it just a little bit easier on ourselves, and continue. Now let's go back and create that product display node that includes all of the flavors of olive oil that we have. To do that, go up to Add product display, say the title is Half-liter bottle of olive oil (plain and flavored). Go back to my exercise file and copy the description here. I am going to select multiple products.

On Windows, you do that by holding the Control key, and on Mac, you do that by holding the Command key, and just selecting the ones that you want, so Olive oil, Lemon-flavored, and Chili-flavored. The type is all Edible oils. Scroll down, and save. Now, you will notice it defaults to Plain as we wanted, and it shows it as $10, but if I change it to Lemon, we immediately see the different product. Same is true for Chili, and if in fact we had different prices, it would have changed the price, and any other attributes.

This is a wonderful way to create a single display node that's more convenient for people to shop. The last thing that I'm going to do is I am going to go back to my list of content, and unpublish the ones that we don't need anymore. We don't need to have all four nodes; one of them that holds three, and the other three individual ones. So I will take Chili-flavored, Lemon-flavored, and ordinary one, and Unpublish it. Now if we go back to our front page, we have the Half-liter bottle of olive oil, and the Lip balm; much cleaner. Pretty cool, huh? But I know what you're thinking.

You are thinking, does this mean we have to add every variation of our product by hand? And the answer is well, yeah, basically. But there is a module that does that, and it takes away a lot of the heavy lifting. It's called Commerce Bulk Product Creation, and you can get it at drupal.org/project/commerce_bpc. If you have trouble installing it, see the video expanding a site's capabilities with modules in lynda.com series Drupal 7 Essential Training.

Show transcript

This video is part of

Image for Create Your First Online Store with Drupal Commerce
Create Your First Online Store with Drupal Commerce

35 video lessons · 11203 viewers

Tom Geller
Author

 
Expand all | Collapse all
  1. 16m 44s
    1. Welcome
      54s
    2. Previewing the finished project
      4m 10s
    3. Surveying the store-building process
      4m 29s
    4. Using the exercise files
      7m 11s
  2. 12m 12s
    1. Installing Drupal Commerce using Commerce Kickstart
      6m 5s
    2. Configuring your store's basic information
      6m 7s
  3. 31m 29s
    1. Accepting PayPal payments
      5m 9s
    2. Setting up individual products
      3m 17s
    3. Displaying products
      6m 30s
    4. Categorizing products
      5m 31s
    5. Adding simple taxes
      4m 39s
    6. Seeing your site from the customer's viewpoint
      3m 26s
    7. Processing orders
      2m 57s
  4. 17m 39s
    1. Understanding products and other entities
      3m 3s
    2. Understanding line items
      3m 16s
    3. Understanding rules
      5m 10s
    4. Integrating your store into a Drupal site
      6m 10s
  5. 29m 46s
    1. Adding product variations
      7m 2s
    2. Managing product variations
      3m 50s
    3. Importing simple products
      10m 11s
    4. Importing complicated products
      8m 43s
  6. 29m 52s
    1. Shipping products
      4m 50s
    2. Managing inventory
      4m 30s
    3. Managing orders
      5m 39s
    4. Managing customer profiles
      4m 55s
    5. Using Views to gain better oversight
      5m 0s
    6. Accepting other payment methods
      4m 58s
  7. 24m 52s
    1. Changing your store's look
      6m 24s
    2. Streamlining the checkout process
      5m 19s
    3. Launching your store
      13m 9s
  8. 29m 25s
    1. Offering product discounts
      8m 56s
    2. Gaining insight from Google Analytics
      5m 45s
    3. Making your site more visible to search engines (SEO)
      5m 52s
    4. Encouraging customer buzz
      8m 52s
  9. 56s
    1. Goodbye
      56s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Create Your First Online Store with Drupal Commerce .

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.