Using Views to gain better oversight
Video: Using Views to gain better oversightWhat you're about to see might be the most powerful video of the entire course. That's because you're going to learn about one of the systems that underlies your entire store, and once you understand how it works, you will be able to change the organization of pretty much everything in it. This magical system is called views, and it's included as part of Drupal Commerce. Views is the single most popular extension to Drupal, and it's quite complex. This video gives you only a peek into its power, but it'll be enough to let us see at a glance how many of each product we have in stock.
Viewers: in countries Watching now:
This course shows how to build an online store using Drupal Commerce, a set of modules that extend Drupal. Author Tom Geller teaches the basics of configuring a store, processing a payment, and charging for shipping and taxes, as well as creating, displaying, and categorizing products. The course also explains how to integrate a store into a Drupal site, customize a store's appearance, and increase site traffic using search engine optimization (SEO) techniques.
- Surveying the store-building process
- Installing Drupal Commerce using Commerce Kickstart
- Accepting PayPal payments
- Processing orders
- Understanding rules and line items
- Listing and importing products
- Managing inventory, orders, and customer profiles
- Streamlining the checkout process
- Launching a store
- Offering product discounts
- Analyzing site traffic with Google Analytics
Using Views to gain better oversight
What you're about to see might be the most powerful video of the entire course. That's because you're going to learn about one of the systems that underlies your entire store, and once you understand how it works, you will be able to change the organization of pretty much everything in it. This magical system is called views, and it's included as part of Drupal Commerce. Views is the single most popular extension to Drupal, and it's quite complex. This video gives you only a peek into its power, but it'll be enough to let us see at a glance how many of each product we have in stock.
First, let's look at how we see products by default. To do that, we go to Store, and Products, or of course, we could just click View products. In the video about managing inventory, we added a module that keeps track of our holdings, but we don't actually see that in this list. We look at any particular product, say by editing Olive oil; there is our Stock field. But let's go back to our list of products. One thing you might not have noticed throughout this course is when you move your cursor over it, you see this little gear up here.
This is what's called a contextual menu. It lets you edit the view that you're seeing here. You see, this list is actually just a simple view, which you can edit. So we go up, and click it, and Edit view. By the way, there is another way to get there. You would click Structure, and Views, and then find the view that you want. To tell you the truth, I prefer to do it through the contextual menu, because then I know exactly what I'm editing. The way we are going to add that field is actually fairly simple. We go down here to this Field section, and click add. I am then going to do a search for stock, and there it is; Commerce Product: Stock.
Add and configure fields. I'll just leave it in its default, and then before you do anything else, you might want to see what it looks like. So we will scroll down, and look at the preview, and there's our stock. If we wanted, we could move it around by clicking rearrange. Let's say, move it up a little bit, and apply it. All sorts of things you can do in views, but before we go, we have to save it. So scroll up to the top, and click Save. Now as you see, we are here on our View products list, and there's our stock. The great thing is, you can do this on just about any screen in your store, and with views, you can do a lot more than just add fields.
Here; I will show you with the order screen. We go to View orders, and then click this contextual menu to edit the view. Here I am going to change the filtering, so we are going to add an exposed filter. Click add, and add order total. Again, I just happened to know this, but you could scroll through and see which one you wanted. This is the one I want. So I will add and configure. I will expose this filter, and say that I only want to see those orders which are, let's say, greater than 10, and apply.
By the way, I am doing a mistake here, which I will show you in a minute. If we scroll down to the bottom here, we see we now have this filter available to us. Let's go ahead and save, and see what that looks like. Again, if I click View orders, there it is. I can change the filter here, like let's say we only want to see things that are above 20. That should cut out this one that's $19, right? Oh! But it didn't. So I must've done something wrong. Let's go back in and check. Edit view, go down to our filter, and edit this particular one.
Now, as it turns out, the thing that you need to know is that it's counting by pennies, not dollars. This is the kind of error that will drive you crazy when you go through it. The thing I would recommend is go and take a look at the documentation that's either on drupalcommerce.org, or drupal.org/project/views. I am going to change this so that it shows us $10 by default. Then I will go back up and save it. Now if I want to see only those things that are above $20, I'll enter 2000, and apply, and indeed, everything below $20 drops out.
But you know what? I don't think I like having this available. Fortunately, I can revert it back to its factory settings. So once again, I'll go up to my contextual menu, and edit the view. Now, here I will notice, the name of the view is Orders (Commerce Order). In order to change this view, I have to go up one level to where it shows all the views, and then find that one. Orders, yep, that looks like the one. I will go back here, and choose revert. Yep, that's really what I wanted to do. Now if I go back and view orders, it's as it was before; there is no filter.
I do have to warn you, though: you can't revert views that you specifically create, and as you can see, you can get yourself into a lot of trouble with them. If you really want to play around with them, I strongly recommend you watch my Drupal 7 Reporting and Visualizing Data series on lynda.com. It's really amazing what you can do with views, though. You can, for example, create a map of all of your customers' shipping addresses, add totals to the order page, and so much more. You don't need to do that to run a successful store, of course, but the flexibility that you get with views is worth the learning curve.
Find answers to the most frequently asked questions about Create Your First Online Store with Drupal Commerce .
Here are the FAQs that matched your search "" :
- Q; Where can I learn more about how to make a website?
- A: Discover more on this topic by visiting how to make a website on lynda.com.
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.